Moved constraints to a DynMath project (repo MightyPork/dynmath)

master
Ondřej Hruška 11 years ago
parent 0f2cb0b985
commit dca4b58b86
  1. 1
      .classpath
  2. 1
      src/mightypork/gamecore/eventbus/events/UpdateEvent.java
  3. 10
      src/mightypork/gamecore/gui/components/BaseComponent.java
  4. 2
      src/mightypork/gamecore/gui/components/Component.java
  5. 2
      src/mightypork/gamecore/gui/components/LayoutComponent.java
  6. 10
      src/mightypork/gamecore/gui/components/LinearComponent.java
  7. 6
      src/mightypork/gamecore/gui/components/PluggableRenderable.java
  8. 4
      src/mightypork/gamecore/gui/components/input/TextButton.java
  9. 2
      src/mightypork/gamecore/gui/components/layout/ColumnLayout.java
  10. 2
      src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java
  11. 6
      src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java
  12. 6
      src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java
  13. 4
      src/mightypork/gamecore/gui/components/layout/GridLayout.java
  14. 2
      src/mightypork/gamecore/gui/components/layout/RowLayout.java
  15. 2
      src/mightypork/gamecore/gui/components/layout/linear/LinearGap.java
  16. 10
      src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java
  17. 2
      src/mightypork/gamecore/gui/components/layout/linear/LinearRectangle.java
  18. 6
      src/mightypork/gamecore/gui/components/painters/TextPainter.java
  19. 6
      src/mightypork/gamecore/gui/screens/Overlay.java
  20. 4
      src/mightypork/gamecore/gui/screens/Screen.java
  21. 2
      src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java
  22. 2
      src/mightypork/gamecore/gui/screens/impl/FadingLayer.java
  23. 6
      src/mightypork/gamecore/input/InputSystem.java
  24. 6
      src/mightypork/gamecore/input/events/MouseButtonEvent.java
  25. 4
      src/mightypork/gamecore/input/events/MouseMotionEvent.java
  26. 6
      src/mightypork/gamecore/render/DisplaySystem.java
  27. 8
      src/mightypork/gamecore/render/Render.java
  28. 2
      src/mightypork/gamecore/render/events/ViewportChangeEvent.java
  29. 2
      src/mightypork/gamecore/resources/audio/LazyAudio.java
  30. 6
      src/mightypork/gamecore/resources/audio/SoundSystem.java
  31. 2
      src/mightypork/gamecore/resources/audio/players/EffectPlayer.java
  32. 4
      src/mightypork/gamecore/resources/audio/players/LoopPlayer.java
  33. 4
      src/mightypork/gamecore/resources/fonts/FontRenderer.java
  34. 2
      src/mightypork/gamecore/resources/fonts/GLFont.java
  35. 2
      src/mightypork/gamecore/resources/fonts/impl/LazyFont.java
  36. 4
      src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java
  37. 2
      src/mightypork/gamecore/resources/textures/GLTexture.java
  38. 2
      src/mightypork/gamecore/resources/textures/LazyTexture.java
  39. 2
      src/mightypork/gamecore/resources/textures/QuadGrid.java
  40. 2
      src/mightypork/gamecore/resources/textures/TextureRegistry.java
  41. 4
      src/mightypork/gamecore/resources/textures/TxQuad.java
  42. 2
      src/mightypork/gamecore/util/math/Calc.java
  43. 2
      src/mightypork/gamecore/util/math/Polar.java
  44. 4
      src/mightypork/gamecore/util/math/algo/Coord.java
  45. 2
      src/mightypork/gamecore/util/math/color/Color.java
  46. 2
      src/mightypork/gamecore/util/math/color/ColorAlphaAdjuster.java
  47. 2
      src/mightypork/gamecore/util/math/color/ColorHsb.java
  48. 2
      src/mightypork/gamecore/util/math/color/ColorRgb.java
  49. 44
      src/mightypork/gamecore/util/math/constraints/ConstraintCache.java
  50. 60
      src/mightypork/gamecore/util/math/constraints/DigestCache.java
  51. 60
      src/mightypork/gamecore/util/math/constraints/Digestable.java
  52. 15
      src/mightypork/gamecore/util/math/constraints/Pollable.java
  53. 47
      src/mightypork/gamecore/util/math/constraints/Poller.java
  54. 760
      src/mightypork/gamecore/util/math/constraints/num/Num.java
  55. 270
      src/mightypork/gamecore/util/math/constraints/num/NumConst.java
  56. 49
      src/mightypork/gamecore/util/math/constraints/num/NumSum.java
  57. 84
      src/mightypork/gamecore/util/math/constraints/num/caching/AbstractNumCache.java
  58. 37
      src/mightypork/gamecore/util/math/constraints/num/caching/NumCache.java
  59. 23
      src/mightypork/gamecore/util/math/constraints/num/caching/NumDigest.java
  60. 41
      src/mightypork/gamecore/util/math/constraints/num/mutable/NumMutable.java
  61. 42
      src/mightypork/gamecore/util/math/constraints/num/mutable/NumVar.java
  62. 18
      src/mightypork/gamecore/util/math/constraints/num/proxy/NumAdapter.java
  63. 19
      src/mightypork/gamecore/util/math/constraints/num/proxy/NumBound.java
  64. 36
      src/mightypork/gamecore/util/math/constraints/num/proxy/NumBoundAdapter.java
  65. 24
      src/mightypork/gamecore/util/math/constraints/num/proxy/NumProxy.java
  66. 16
      src/mightypork/gamecore/util/math/constraints/num/proxy/PluggableNumBound.java
  67. 1064
      src/mightypork/gamecore/util/math/constraints/rect/Rect.java
  68. 486
      src/mightypork/gamecore/util/math/constraints/rect/RectConst.java
  69. 130
      src/mightypork/gamecore/util/math/constraints/rect/builders/TiledRect.java
  70. 75
      src/mightypork/gamecore/util/math/constraints/rect/caching/AbstractRectCache.java
  71. 37
      src/mightypork/gamecore/util/math/constraints/rect/caching/RectCache.java
  72. 41
      src/mightypork/gamecore/util/math/constraints/rect/caching/RectDigest.java
  73. 91
      src/mightypork/gamecore/util/math/constraints/rect/mutable/RectMutable.java
  74. 55
      src/mightypork/gamecore/util/math/constraints/rect/mutable/RectVar.java
  75. 16
      src/mightypork/gamecore/util/math/constraints/rect/proxy/PluggableRectBound.java
  76. 58
      src/mightypork/gamecore/util/math/constraints/rect/proxy/RectAdapter.java
  77. 18
      src/mightypork/gamecore/util/math/constraints/rect/proxy/RectBound.java
  78. 41
      src/mightypork/gamecore/util/math/constraints/rect/proxy/RectBoundAdapter.java
  79. 24
      src/mightypork/gamecore/util/math/constraints/rect/proxy/RectProxy.java
  80. 39
      src/mightypork/gamecore/util/math/constraints/rect/proxy/RectVectAdapter.java
  81. 1231
      src/mightypork/gamecore/util/math/constraints/vect/Vect.java
  82. 375
      src/mightypork/gamecore/util/math/constraints/vect/VectConst.java
  83. 24
      src/mightypork/gamecore/util/math/constraints/vect/VectProxy.java
  84. 75
      src/mightypork/gamecore/util/math/constraints/vect/caching/AbstractVectCache.java
  85. 37
      src/mightypork/gamecore/util/math/constraints/vect/caching/VectCache.java
  86. 27
      src/mightypork/gamecore/util/math/constraints/vect/caching/VectDigest.java
  87. 80
      src/mightypork/gamecore/util/math/constraints/vect/mutable/VectMutable.java
  88. 78
      src/mightypork/gamecore/util/math/constraints/vect/mutable/VectVar.java
  89. 16
      src/mightypork/gamecore/util/math/constraints/vect/proxy/PluggableVectBound.java
  90. 41
      src/mightypork/gamecore/util/math/constraints/vect/proxy/VectAdapter.java
  91. 18
      src/mightypork/gamecore/util/math/constraints/vect/proxy/VectBound.java
  92. 36
      src/mightypork/gamecore/util/math/constraints/vect/proxy/VectBoundAdapter.java
  93. 57
      src/mightypork/gamecore/util/math/constraints/vect/proxy/VectNumAdapter.java
  94. 3
      src/mightypork/gamecore/util/math/timing/TaskRepeater.java
  95. 4
      src/mightypork/gamecore/util/math/timing/TimedTask.java
  96. 2
      src/mightypork/gamecore/util/math/timing/Updateable.java
  97. 8
      src/mightypork/gamecore/util/math/timing/animation/Animator.java
  98. 3
      src/mightypork/gamecore/util/math/timing/animation/AnimatorBounce.java
  99. 3
      src/mightypork/gamecore/util/math/timing/animation/AnimatorRewind.java
  100. 5
      src/mightypork/gamecore/util/math/timing/animation/NumAnimated.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -33,5 +33,6 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/Ion"/> <classpathentry combineaccessrules="false" kind="src" path="/Ion"/>
<classpathentry combineaccessrules="false" kind="src" path="/DynMath"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

@ -5,6 +5,7 @@ import mightypork.gamecore.eventbus.BusEvent;
import mightypork.gamecore.eventbus.event_flags.DirectEvent; import mightypork.gamecore.eventbus.event_flags.DirectEvent;
import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent; import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent;
import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent; import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent;
import mightypork.gamecore.util.math.timing.Updateable;
/** /**

@ -1,6 +1,11 @@
package mightypork.gamecore.gui.components; package mightypork.gamecore.gui.components;
import mightypork.dynmath.num.Num;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.rect.caching.AbstractRectCache;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.dynmath.rect.proxy.RectBoundAdapter;
import mightypork.gamecore.gui.Enableable; import mightypork.gamecore.gui.Enableable;
import mightypork.gamecore.gui.events.LayoutChangeEvent; import mightypork.gamecore.gui.events.LayoutChangeEvent;
import mightypork.gamecore.gui.events.LayoutChangeListener; import mightypork.gamecore.gui.events.LayoutChangeListener;
@ -9,11 +14,6 @@ import mightypork.gamecore.logging.Log;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.gamecore.util.annot.DefaultImpl; import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.caching.AbstractRectCache;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBoundAdapter;
/** /**

@ -1,9 +1,9 @@
package mightypork.gamecore.gui.components; package mightypork.gamecore.gui.components;
import mightypork.dynmath.num.Num;
import mightypork.gamecore.gui.Enableable; import mightypork.gamecore.gui.Enableable;
import mightypork.gamecore.gui.Hideable; import mightypork.gamecore.gui.Hideable;
import mightypork.gamecore.util.math.constraints.num.Num;
/** /**

@ -4,6 +4,7 @@ package mightypork.gamecore.gui.components;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppSubModule; import mightypork.gamecore.core.modules.AppSubModule;
import mightypork.gamecore.eventbus.EventBus; import mightypork.gamecore.eventbus.EventBus;
@ -11,7 +12,6 @@ import mightypork.gamecore.eventbus.clients.ClientHub;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem; import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.audio.SoundSystem; import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
public abstract class LayoutComponent extends BaseComponent implements ClientHub, AppAccess { public abstract class LayoutComponent extends BaseComponent implements ClientHub, AppAccess {

@ -1,11 +1,11 @@
package mightypork.gamecore.gui.components; package mightypork.gamecore.gui.components;
import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.dynmath.num.Num;
import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.dynmath.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound; import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter; import mightypork.dynmath.vect.proxy.VectAdapter;
public abstract class LinearComponent extends BaseComponent implements DynamicWidthComponent { public abstract class LinearComponent extends BaseComponent implements DynamicWidthComponent {

@ -1,10 +1,10 @@
package mightypork.gamecore.gui.components; package mightypork.gamecore.gui.components;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.rect.proxy.PluggableRectBound;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.proxy.PluggableRectBound;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/** /**

@ -1,6 +1,8 @@
package mightypork.gamecore.gui.components.input; package mightypork.gamecore.gui.components.input;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.mutable.VectVar;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.DynamicWidthComponent; import mightypork.gamecore.gui.components.DynamicWidthComponent;
import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.components.painters.TextPainter;
@ -8,8 +10,6 @@ import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.color.pal.RGB; import mightypork.gamecore.util.math.color.pal.RGB;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar;
/** /**

@ -1,9 +1,9 @@
package mightypork.gamecore.gui.components.layout; package mightypork.gamecore.gui.components.layout;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.components.Component; import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
public class ColumnLayout extends GridLayout { public class ColumnLayout extends GridLayout {

@ -1,10 +1,10 @@
package mightypork.gamecore.gui.components.layout; package mightypork.gamecore.gui.components.layout;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.components.Component; import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.gui.components.LayoutComponent; import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/** /**

@ -1,13 +1,13 @@
package mightypork.gamecore.gui.components.layout; package mightypork.gamecore.gui.components.layout;
import mightypork.dynmath.num.Num;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.Component; import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.gui.components.LayoutComponent; import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/** /**

@ -1,13 +1,13 @@
package mightypork.gamecore.gui.components.layout; package mightypork.gamecore.gui.components.layout;
import mightypork.dynmath.num.Num;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.AlignY; import mightypork.gamecore.gui.AlignY;
import mightypork.gamecore.gui.components.Component; import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.gui.components.LayoutComponent; import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/** /**

@ -1,11 +1,11 @@
package mightypork.gamecore.gui.components.layout; package mightypork.gamecore.gui.components.layout;
import mightypork.dynmath.rect.builders.TiledRect;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.components.Component; import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.gui.components.LayoutComponent; import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.util.math.constraints.rect.builders.TiledRect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/** /**

@ -1,9 +1,9 @@
package mightypork.gamecore.gui.components.layout; package mightypork.gamecore.gui.components.layout;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.components.Component; import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
public class RowLayout extends GridLayout { public class RowLayout extends GridLayout {

@ -1,8 +1,8 @@
package mightypork.gamecore.gui.components.layout.linear; package mightypork.gamecore.gui.components.layout.linear;
import mightypork.dynmath.num.Num;
import mightypork.gamecore.gui.components.layout.NullComponent; import mightypork.gamecore.gui.components.layout.NullComponent;
import mightypork.gamecore.util.math.constraints.num.Num;
/** /**

@ -1,16 +1,16 @@
package mightypork.gamecore.gui.components.layout.linear; package mightypork.gamecore.gui.components.layout.linear;
import mightypork.dynmath.num.Num;
import mightypork.dynmath.num.NumSum;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.proxy.VectAdapter;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.DynamicWidthComponent; import mightypork.gamecore.gui.components.DynamicWidthComponent;
import mightypork.gamecore.gui.components.LayoutComponent; import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.gui.components.LinearComponent; import mightypork.gamecore.gui.components.LinearComponent;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.num.NumSum;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter;
public class LinearLayout extends LayoutComponent { public class LinearLayout extends LayoutComponent {

@ -1,8 +1,8 @@
package mightypork.gamecore.gui.components.layout.linear; package mightypork.gamecore.gui.components.layout.linear;
import mightypork.dynmath.num.Num;
import mightypork.gamecore.gui.components.Component; import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.util.math.constraints.num.Num;
public class LinearRectangle extends AbstractLinearWrapper { public class LinearRectangle extends AbstractLinearWrapper {

@ -1,6 +1,9 @@
package mightypork.gamecore.gui.components.painters; package mightypork.gamecore.gui.components.painters;
import mightypork.dynmath.num.Num;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.BaseComponent; import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.gui.components.DynamicWidthComponent; import mightypork.gamecore.gui.components.DynamicWidthComponent;
@ -9,9 +12,6 @@ import mightypork.gamecore.resources.fonts.FontRenderer;
import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.color.pal.RGB; import mightypork.gamecore.util.math.color.pal.RGB;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.strings.StringProvider; import mightypork.gamecore.util.strings.StringProvider;
import mightypork.gamecore.util.strings.StringWrapper; import mightypork.gamecore.util.strings.StringWrapper;

@ -4,9 +4,10 @@ package mightypork.gamecore.gui.screens;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import mightypork.dynmath.num.Num;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppSubModule; import mightypork.gamecore.core.modules.AppSubModule;
import mightypork.gamecore.eventbus.events.Updateable;
import mightypork.gamecore.gui.Enableable; import mightypork.gamecore.gui.Enableable;
import mightypork.gamecore.gui.Hideable; import mightypork.gamecore.gui.Hideable;
import mightypork.gamecore.gui.components.layout.ConstraintLayout; import mightypork.gamecore.gui.components.layout.ConstraintLayout;
@ -18,8 +19,7 @@ import mightypork.gamecore.input.KeyStroke.Edge;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.gamecore.util.annot.DefaultImpl; import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.gamecore.util.math.timing.Updateable;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/** /**

@ -1,6 +1,8 @@
package mightypork.gamecore.gui.screens; package mightypork.gamecore.gui.screens;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppSubModule; import mightypork.gamecore.core.modules.AppSubModule;
import mightypork.gamecore.gui.events.LayoutChangeEvent; import mightypork.gamecore.gui.events.LayoutChangeEvent;
@ -13,8 +15,6 @@ import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.render.Render; import mightypork.gamecore.render.Render;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.gamecore.util.annot.DefaultImpl; import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/** /**

@ -8,8 +8,8 @@ import mightypork.gamecore.gui.events.ScreenRequest;
import mightypork.gamecore.gui.screens.Overlay; import mightypork.gamecore.gui.screens.Overlay;
import mightypork.gamecore.util.math.Easing; import mightypork.gamecore.util.math.Easing;
import mightypork.gamecore.util.math.color.pal.RGB; import mightypork.gamecore.util.math.color.pal.RGB;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
import mightypork.gamecore.util.math.timing.TimedTask; import mightypork.gamecore.util.math.timing.TimedTask;
import mightypork.gamecore.util.math.timing.animation.NumAnimated;
/** /**

@ -5,8 +5,8 @@ import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.util.annot.DefaultImpl; import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.Easing; import mightypork.gamecore.util.math.Easing;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
import mightypork.gamecore.util.math.timing.TimedTask; import mightypork.gamecore.util.math.timing.TimedTask;
import mightypork.gamecore.util.math.timing.animation.NumAnimated;
/** /**

@ -1,17 +1,17 @@
package mightypork.gamecore.input; package mightypork.gamecore.input;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.mutable.VectVar;
import mightypork.gamecore.core.events.UserQuitRequest; import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.eventbus.clients.RootBusNode; import mightypork.gamecore.eventbus.clients.RootBusNode;
import mightypork.gamecore.eventbus.events.Updateable;
import mightypork.gamecore.input.KeyStroke.Edge; import mightypork.gamecore.input.KeyStroke.Edge;
import mightypork.gamecore.input.events.InputReadyEvent; import mightypork.gamecore.input.events.InputReadyEvent;
import mightypork.gamecore.input.events.KeyEvent; import mightypork.gamecore.input.events.KeyEvent;
import mightypork.gamecore.input.events.MouseButtonEvent; import mightypork.gamecore.input.events.MouseButtonEvent;
import mightypork.gamecore.input.events.MouseMotionEvent; import mightypork.gamecore.input.events.MouseMotionEvent;
import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.gamecore.util.math.timing.Updateable;
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;

@ -1,11 +1,11 @@
package mightypork.gamecore.input.events; package mightypork.gamecore.input.events;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.VectConst;
import mightypork.gamecore.eventbus.BusEvent; import mightypork.gamecore.eventbus.BusEvent;
import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent; import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.VectConst;
/** /**

@ -1,10 +1,10 @@
package mightypork.gamecore.input.events; package mightypork.gamecore.input.events;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.VectConst;
import mightypork.gamecore.eventbus.BusEvent; import mightypork.gamecore.eventbus.BusEvent;
import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent; import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.VectConst;
/** /**

@ -5,14 +5,14 @@ import static org.lwjgl.opengl.GL11.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.rect.proxy.RectBound;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppModule; import mightypork.gamecore.core.modules.AppModule;
import mightypork.gamecore.logging.Log; import mightypork.gamecore.logging.Log;
import mightypork.gamecore.render.events.DisplayReadyEvent; import mightypork.gamecore.render.events.DisplayReadyEvent;
import mightypork.gamecore.render.events.ViewportChangeEvent; import mightypork.gamecore.render.events.ViewportChangeEvent;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.timing.FpsMeter; import mightypork.gamecore.util.math.timing.FpsMeter;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;

@ -5,6 +5,10 @@ import static org.lwjgl.opengl.GL11.*;
import java.io.IOException; import java.io.IOException;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.rect.caching.RectDigest;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.VectConst;
import mightypork.gamecore.logging.Log; import mightypork.gamecore.logging.Log;
import mightypork.gamecore.resources.textures.FilterMode; import mightypork.gamecore.resources.textures.FilterMode;
import mightypork.gamecore.resources.textures.GLTexture; import mightypork.gamecore.resources.textures.GLTexture;
@ -12,10 +16,6 @@ import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.gamecore.util.files.FileUtils; import mightypork.gamecore.util.files.FileUtils;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.color.pal.RGB; import mightypork.gamecore.util.math.color.pal.RGB;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.caching.RectDigest;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.VectConst;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;

@ -1,10 +1,10 @@
package mightypork.gamecore.render.events; package mightypork.gamecore.render.events;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.eventbus.BusEvent; import mightypork.gamecore.eventbus.BusEvent;
import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent; import mightypork.gamecore.eventbus.event_flags.NonConsumableEvent;
import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent; import mightypork.gamecore.eventbus.event_flags.NotLoggedEvent;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/** /**

@ -4,10 +4,10 @@ package mightypork.gamecore.resources.audio;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.logging.LogAlias; import mightypork.gamecore.logging.LogAlias;
import mightypork.gamecore.resources.BaseLazyResource; import mightypork.gamecore.resources.BaseLazyResource;
import mightypork.gamecore.util.files.FileUtils; import mightypork.gamecore.util.files.FileUtils;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import org.newdawn.slick.openal.Audio; import org.newdawn.slick.openal.Audio;
import org.newdawn.slick.openal.SoundStore; import org.newdawn.slick.openal.SoundStore;

@ -5,16 +5,16 @@ import java.nio.FloatBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.mutable.VectVar;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.eventbus.clients.RootBusNode; import mightypork.gamecore.eventbus.clients.RootBusNode;
import mightypork.gamecore.eventbus.events.Updateable;
import mightypork.gamecore.logging.Log; import mightypork.gamecore.logging.Log;
import mightypork.gamecore.resources.ResourceLoadRequest; import mightypork.gamecore.resources.ResourceLoadRequest;
import mightypork.gamecore.resources.audio.players.EffectPlayer; import mightypork.gamecore.resources.audio.players.EffectPlayer;
import mightypork.gamecore.resources.audio.players.LoopPlayer; import mightypork.gamecore.resources.audio.players.LoopPlayer;
import mightypork.gamecore.util.math.Calc.Buffers; import mightypork.gamecore.util.math.Calc.Buffers;
import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.gamecore.util.math.timing.Updateable;
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar;
import org.lwjgl.openal.AL; import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10; import org.lwjgl.openal.AL10;

@ -1,9 +1,9 @@
package mightypork.gamecore.resources.audio.players; package mightypork.gamecore.resources.audio.players;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.resources.audio.LazyAudio; import mightypork.gamecore.resources.audio.LazyAudio;
import mightypork.gamecore.resources.audio.Volume; import mightypork.gamecore.resources.audio.Volume;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/** /**

@ -1,11 +1,11 @@
package mightypork.gamecore.resources.audio.players; package mightypork.gamecore.resources.audio.players;
import mightypork.gamecore.eventbus.events.Updateable;
import mightypork.gamecore.resources.audio.LazyAudio; import mightypork.gamecore.resources.audio.LazyAudio;
import mightypork.gamecore.resources.audio.Volume; import mightypork.gamecore.resources.audio.Volume;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
import mightypork.gamecore.util.math.timing.Pauseable; import mightypork.gamecore.util.math.timing.Pauseable;
import mightypork.gamecore.util.math.timing.Updateable;
import mightypork.gamecore.util.math.timing.animation.NumAnimated;
import org.lwjgl.openal.AL10; import org.lwjgl.openal.AL10;

@ -1,12 +1,12 @@
package mightypork.gamecore.resources.fonts; package mightypork.gamecore.resources.fonts;
import mightypork.dynmath.rect.Rect;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.render.Render; import mightypork.gamecore.render.Render;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.color.pal.RGB; import mightypork.gamecore.util.math.color.pal.RGB;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/** /**

@ -1,8 +1,8 @@
package mightypork.gamecore.resources.fonts; package mightypork.gamecore.resources.fonts;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/** /**

@ -6,6 +6,7 @@ import java.awt.FontFormatException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import mightypork.dynmath.vect.Vect;
import mightypork.gamecore.logging.LogAlias; import mightypork.gamecore.logging.LogAlias;
import mightypork.gamecore.resources.BaseLazyResource; import mightypork.gamecore.resources.BaseLazyResource;
import mightypork.gamecore.resources.TextureBasedResource; import mightypork.gamecore.resources.TextureBasedResource;
@ -13,7 +14,6 @@ import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.gamecore.resources.textures.FilterMode; import mightypork.gamecore.resources.textures.FilterMode;
import mightypork.gamecore.util.files.FileUtils; import mightypork.gamecore.util.files.FileUtils;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/** /**

@ -18,13 +18,13 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.VectConst;
import mightypork.gamecore.logging.Log; import mightypork.gamecore.logging.Log;
import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.gamecore.resources.textures.FilterMode; import mightypork.gamecore.resources.textures.FilterMode;
import mightypork.gamecore.resources.textures.LazyTexture; import mightypork.gamecore.resources.textures.LazyTexture;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.VectConst;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.util.glu.GLU; import org.lwjgl.util.glu.GLU;

@ -1,8 +1,8 @@
package mightypork.gamecore.resources.textures; package mightypork.gamecore.resources.textures;
import mightypork.dynmath.rect.Rect;
import mightypork.gamecore.eventbus.events.Destroyable; import mightypork.gamecore.eventbus.events.Destroyable;
import mightypork.gamecore.util.math.constraints.rect.Rect;
/** /**

@ -1,11 +1,11 @@
package mightypork.gamecore.resources.textures; package mightypork.gamecore.resources.textures;
import mightypork.dynmath.rect.Rect;
import mightypork.gamecore.logging.LogAlias; import mightypork.gamecore.logging.LogAlias;
import mightypork.gamecore.render.Render; import mightypork.gamecore.render.Render;
import mightypork.gamecore.resources.BaseLazyResource; import mightypork.gamecore.resources.BaseLazyResource;
import mightypork.gamecore.resources.TextureBasedResource; import mightypork.gamecore.resources.TextureBasedResource;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;

@ -1,7 +1,7 @@
package mightypork.gamecore.resources.textures; package mightypork.gamecore.resources.textures;
import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.dynmath.rect.Rect;
/** /**

@ -4,11 +4,11 @@ package mightypork.gamecore.resources.textures;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import mightypork.dynmath.rect.Rect;
import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.core.modules.AppAccessAdapter; import mightypork.gamecore.core.modules.AppAccessAdapter;
import mightypork.gamecore.resources.ResourceLoadRequest; import mightypork.gamecore.resources.ResourceLoadRequest;
import mightypork.gamecore.util.error.KeyAlreadyExistsException; import mightypork.gamecore.util.error.KeyAlreadyExistsException;
import mightypork.gamecore.util.math.constraints.rect.Rect;
/** /**

@ -1,8 +1,8 @@
package mightypork.gamecore.resources.textures; package mightypork.gamecore.resources.textures;
import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.dynmath.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.RectConst; import mightypork.dynmath.rect.RectConst;
/** /**

@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.dynmath.vect.Vect;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;

@ -1,7 +1,7 @@
package mightypork.gamecore.util.math; package mightypork.gamecore.util.math;
import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.dynmath.vect.Vect;
/** /**

@ -3,10 +3,10 @@ package mightypork.gamecore.util.math.algo;
import java.io.IOException; import java.io.IOException;
import mightypork.dynmath.vect.Vect;
import mightypork.dynmath.vect.VectConst;
import mightypork.gamecore.util.annot.FactoryMethod; import mightypork.gamecore.util.annot.FactoryMethod;
import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.Calc;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.VectConst;
import mightypork.ion.IonBundle; import mightypork.ion.IonBundle;
import mightypork.ion.IonInput; import mightypork.ion.IonInput;
import mightypork.ion.IonObjBinary; import mightypork.ion.IonObjBinary;

@ -4,9 +4,9 @@ package mightypork.gamecore.util.math.color;
import java.util.EmptyStackException; import java.util.EmptyStackException;
import java.util.Stack; import java.util.Stack;
import mightypork.dynmath.num.Num;
import mightypork.gamecore.util.annot.FactoryMethod; import mightypork.gamecore.util.annot.FactoryMethod;
import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.Calc;
import mightypork.gamecore.util.math.constraints.num.Num;
/** /**

@ -1,7 +1,7 @@
package mightypork.gamecore.util.math.color; package mightypork.gamecore.util.math.color;
import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.dynmath.num.Num;
public class ColorAlphaAdjuster extends Color { public class ColorAlphaAdjuster extends Color {

@ -1,7 +1,7 @@
package mightypork.gamecore.util.math.color; package mightypork.gamecore.util.math.color;
import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.dynmath.num.Num;
public class ColorHsb extends Color { public class ColorHsb extends Color {

@ -1,7 +1,7 @@
package mightypork.gamecore.util.math.color; package mightypork.gamecore.util.math.color;
import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.dynmath.num.Num;
public class ColorRgb extends Color { public class ColorRgb extends Color {

@ -1,44 +0,0 @@
package mightypork.gamecore.util.math.constraints;
/**
* Constraint cache
*
* @author Ondřej Hruška (MightyPork)
* @param <C> constraint type
*/
public interface ConstraintCache<C> extends Pollable {
/**
* Called after the cache has changed value (and digest).
*/
void onConstraintChanged();
/**
* @return the cached value
*/
C getCacheSource();
/**
* Enable caching & digest caching
*
* @param yes enable caching
*/
void enableCaching(boolean yes);
/**
* @return true if caching is on
*/
boolean isCachingEnabled();
/**
* Update cached value and cached digest (if digest caching is enabled).<br>
* source constraint is polled beforehand.
*/
@Override
void poll();
}

@ -1,60 +0,0 @@
package mightypork.gamecore.util.math.constraints;
/**
* Parametrized implementation of a {@link Digestable}
*
* @author Ondřej Hruška (MightyPork)
* @param <D> digest class
*/
public abstract class DigestCache<D> implements Digestable<D> {
private D last_digest;
private boolean caching_enabled = false;
private boolean dirty = true;
@Override
public final D digest()
{
if (caching_enabled) {
if (dirty || last_digest == null) {
last_digest = createDigest();
dirty = false;
}
return last_digest;
}
return createDigest();
}
/**
* @return fresh new digest
*/
protected abstract D createDigest();
@Override
public final void enableDigestCaching(boolean yes)
{
caching_enabled = yes;
markDigestDirty(); // mark dirty
}
@Override
public final boolean isDigestCachingEnabled()
{
return caching_enabled;
}
@Override
public final void markDigestDirty()
{
dirty = true;
}
}

@ -1,60 +0,0 @@
package mightypork.gamecore.util.math.constraints;
/**
* <p>
* Interface for constraints that support digests. Digest is a small data object
* with final fields, typically primitive, used for processing (such as
* rendering or other very frequent operations).
* </p>
* <p>
* Taking a digest is expensive, so if it needs to be done often and the value
* changes are deterministic (such as, triggered by timing event or screen
* resize), it's useful to cache the last digest and reuse it until such an
* event occurs again.
* </p>
* <p>
* Implementing class typically needs a field to store the last digest, a flag
* that digest caching is enabled, and a flag that a digest is dirty.
* </p>
*
* @author Ondřej Hruška (MightyPork)
* @param <D> digest class
*/
public interface Digestable<D> {
/**
* Take a digest. If digest caching is enabled and the cached digest is
* marked as dirty, a new one should be made.
*
* @return digest
*/
public D digest();
/**
* <p>
* Toggle digest caching.
* </p>
* <p>
* To trigger update of the cache, call the <code>poll()</code> method.
* </p>
*
* @param yes
*/
void enableDigestCaching(boolean yes);
/**
* @return true if digest caching is enabled.
*/
boolean isDigestCachingEnabled();
/**
* If digest caching is enabled, mark current cached value as "dirty". Dirty
* digest should be re-created next time a value is requested.<br>
*/
void markDigestDirty();
}

@ -1,15 +0,0 @@
package mightypork.gamecore.util.math.constraints;
/**
* Can be asked to update it's state
*
* @author Ondřej Hruška (MightyPork)
*/
public interface Pollable {
/**
* Update internal state
*/
void poll();
}

@ -1,47 +0,0 @@
package mightypork.gamecore.util.math.constraints;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* Used to poll a number of {@link Pollable}s
*
* @author Ondřej Hruška (MightyPork)
*/
public class Poller implements Pollable {
private final Set<Pollable> pollables = new LinkedHashSet<>();
/**
* Add a pollable
*
* @param p pollable
*/
public void add(Pollable p)
{
pollables.add(p);
}
/**
* Remove a pollalbe
*
* @param p pollable
*/
public void remove(Pollable p)
{
pollables.remove(p);
}
@Override
public void poll()
{
for (final Pollable p : pollables) {
p.poll();
}
}
}

@ -1,760 +0,0 @@
package mightypork.gamecore.util.math.constraints.num;
import mightypork.gamecore.util.annot.FactoryMethod;
import mightypork.gamecore.util.math.Calc;
import mightypork.gamecore.util.math.constraints.DigestCache;
import mightypork.gamecore.util.math.constraints.Digestable;
import mightypork.gamecore.util.math.constraints.num.caching.NumCache;
import mightypork.gamecore.util.math.constraints.num.caching.NumDigest;
import mightypork.gamecore.util.math.constraints.num.mutable.NumVar;
import mightypork.gamecore.util.math.constraints.num.proxy.NumBound;
import mightypork.gamecore.util.math.constraints.num.proxy.NumBoundAdapter;
import mightypork.gamecore.util.math.constraints.vect.Vect;
public abstract class Num implements NumBound, Digestable<NumDigest> {
public static final NumConst ZERO = Num.make(0);
public static final NumConst ONE = Num.make(1);
@FactoryMethod
public static Num make(NumBound bound)
{
return new NumBoundAdapter(bound);
}
@FactoryMethod
public static NumConst make(double value)
{
return new NumConst(value);
}
@FactoryMethod
public static NumVar makeVar()
{
return makeVar(0);
}
@FactoryMethod
public static NumVar makeVar(double value)
{
return new NumVar(value);
}
@FactoryMethod
public static NumVar makeVar(Num copied)
{
return new NumVar(copied.value());
}
private Num p_ceil;
private Num p_floor;
private Num p_sgn;
private Num p_round;
private Num p_atan;
private Num p_acos;
private Num p_asin;
private Num p_tan;
private Num p_cos;
private Num p_sin;
private Num p_cbrt;
private Num p_sqrt;
private Num p_cube;
private Num p_square;
private Num p_neg;
private Num p_abs;
private final DigestCache<NumDigest> dc = new DigestCache<NumDigest>() {
@Override
protected NumDigest createDigest()
{
return new NumDigest(Num.this);
}
};
public NumConst freeze()
{
return new NumConst(value());
}
/**
* Wrap this constraint into a caching adapter. Value will stay fixed (ie.
* no re-calculations) until cache receives a poll() call.
*
* @return the caching adapter
*/
public NumCache cached()
{
return new NumCache(this);
}
/**
* Get a snapshot of the current state, to be used for processing.
*
* @return digest
*/
@Override
public NumDigest digest()
{
return dc.digest();
}
@Override
public void enableDigestCaching(boolean yes)
{
dc.enableDigestCaching(yes);
}
@Override
public boolean isDigestCachingEnabled()
{
return dc.isDigestCachingEnabled();
}
@Override
public void markDigestDirty()
{
dc.markDigestDirty();
}
@Override
public Num getNum()
{
return this;
}
/**
* @return the number
*/
public abstract double value();
public Num add(final double addend)
{
return new Num() {
private final Num t = Num.this;
@Override
public double value()
{
return t.value() + addend;
}
};
}
public Num add(final Num addend)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return t.value() + addend.value();
}
};
}
public Num sub(final double subtrahend)
{
return add(-subtrahend);
}
public Num abs()
{
if (p_abs == null) p_abs = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.abs(t.value());
}
};
return p_abs;
}
public Num sub(final Num subtrahend)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return t.value() - subtrahend.value();
}
};
}
public Num div(final double factor)
{
return mul(1 / factor);
}
public Num div(final Num factor)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return t.value() / factor.value();
}
};
}
public Num mul(final double factor)
{
return new Num() {
private final Num t = Num.this;
@Override
public double value()
{
return t.value() * factor;
}
};
}
public Num mul(final Num factor)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return t.value() * factor.value();
}
};
}
public Num average(final double other)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return (t.value() + other) / 2;
}
};
}
public Num average(final Num other)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return (t.value() + other.value()) / 2;
}
};
}
public Num perc(final double percent)
{
return mul(percent / 100D);
}
public Num perc(final Num percent)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return t.value() * (percent.value() / 100);
}
};
}
public Num cos()
{
if (p_cos == null) p_cos = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.cos(t.value());
}
};
return p_cos;
}
public Num acos()
{
if (p_acos == null) p_acos = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.acos(t.value());
}
};
return p_acos;
}
public Num sin()
{
if (p_sin == null) p_sin = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.sin(t.value());
}
};
return p_sin;
}
public Num asin()
{
if (p_asin == null) p_asin = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.asin(t.value());
}
};
return p_asin;
}
public Num tan()
{
if (p_tan == null) p_tan = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.tan(t.value());
}
};
return p_tan;
}
public Num atan()
{
if (p_atan == null) p_atan = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.atan(t.value());
}
};
return p_atan;
}
public Num cbrt()
{
if (p_cbrt == null) p_cbrt = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.cbrt(t.value());
}
};
return p_cbrt;
}
public Num sqrt()
{
if (p_sqrt == null) p_sqrt = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.sqrt(t.value());
}
};
return p_sqrt;
}
public Num neg()
{
if (p_neg == null) p_neg = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return -1 * t.value();
}
};
return p_neg;
}
public Num round()
{
if (p_round == null) p_round = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.round(t.value());
}
};
return p_round;
}
public Num floor()
{
if (p_floor == null) p_floor = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.floor(t.value());
}
};
return p_floor;
}
public Num ceil()
{
if (p_ceil == null) p_ceil = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.round(t.value());
}
};
return p_ceil;
}
public Num pow(final double other)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.pow(t.value(), other);
}
};
}
public Num pow(final Num power)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.pow(t.value(), power.value());
}
};
}
public Num cube()
{
if (p_cube == null) p_cube = new Num() {
final Num t = Num.this;
@Override
public double value()
{
final double v = t.value();
return v * v * v;
}
};
return p_cube;
}
public Num square()
{
if (p_square == null) p_square = new Num() {
final Num t = Num.this;
@Override
public double value()
{
final double v = t.value();
return v * v;
}
};
return p_square;
}
public Num half()
{
return mul(0.5);
}
public Num max(final double other)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.max(t.value(), other);
}
};
}
public Num max(final Num other)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.max(t.value(), other.value());
}
};
}
public Num min(final Num other)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.min(t.value(), other.value());
}
};
}
public Num min(final double other)
{
return new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.min(t.value(), other);
}
};
}
public Num signum()
{
if (p_sgn == null) p_sgn = new Num() {
final Num t = Num.this;
@Override
public double value()
{
return Math.signum(t.value());
}
};
return p_sgn;
}
public boolean isNegative()
{
return value() < 0;
}
public boolean isPositive()
{
return value() > 0;
}
public boolean isZero()
{
return value() == 0;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(value());
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (!(obj instanceof Num)) return false;
final Num other = (Num) obj;
return value() == other.value();
}
@Override
public String toString()
{
return Calc.toString(value());
}
/**
* @return vect with both coords of this size
*/
public Vect toVectXY()
{
return Vect.make(this);
}
}

@ -1,270 +0,0 @@
package mightypork.gamecore.util.math.constraints.num;
import mightypork.gamecore.util.math.constraints.num.caching.NumDigest;
/**
* Constant number.<br>
* It's arranged so that operations with constant arguments yield constant
* results.
*
* @author Ondřej Hruška (MightyPork)
*/
public class NumConst extends Num {
private final double value;
private NumDigest digest;
NumConst(Num copied)
{
this.value = copied.value();
}
NumConst(double value)
{
this.value = value;
}
@Override
public double value()
{
return value;
}
/**
* @deprecated No good to copy a constant.
*/
@Override
@Deprecated
public NumConst freeze()
{
return this;
}
@Override
public NumDigest digest()
{
return (digest != null) ? digest : (digest = super.digest());
}
@Override
public NumConst add(double addend)
{
return Num.make(value() + addend);
}
public NumConst add(NumConst addend)
{
return Num.make(value + addend.value);
}
@Override
public NumConst sub(double subtrahend)
{
return add(-subtrahend);
}
public NumConst sub(NumConst addend)
{
return Num.make(value - addend.value);
}
@Override
public NumConst mul(double factor)
{
return Num.make(value() * factor);
}
public NumConst mul(NumConst addend)
{
return Num.make(value * addend.value);
}
@Override
public NumConst div(double factor)
{
return mul(1 / factor);
}
public NumConst div(NumConst addend)
{
return Num.make(value / addend.value);
}
@Override
public NumConst perc(double percents)
{
return mul(percents / 100);
}
@Override
public NumConst neg()
{
return mul(-1);
}
@Override
public NumConst abs()
{
return Num.make(Math.abs(value()));
}
@Override
public NumConst max(double other)
{
return Num.make(Math.max(value(), other));
}
@Override
public NumConst min(double other)
{
return Num.make(Math.min(value(), other));
}
@Override
public NumConst pow(double power)
{
return Num.make(Math.pow(value(), power));
}
@Override
public NumConst square()
{
final double v = value();
return Num.make(v * v);
}
@Override
public NumConst cube()
{
final double v = value();
return Num.make(v * v * v);
}
@Override
public NumConst sqrt()
{
return Num.make(Math.sqrt(value()));
}
@Override
public NumConst cbrt()
{
return Num.make(Math.cbrt(value()));
}
@Override
public NumConst sin()
{
return Num.make(Math.sin(value()));
}
@Override
public NumConst cos()
{
return Num.make(Math.cos(value()));
}
@Override
public NumConst tan()
{
return Num.make(Math.tan(value()));
}
@Override
public NumConst asin()
{
return Num.make(Math.asin(value()));
}
@Override
public NumConst acos()
{
return Num.make(Math.acos(value()));
}
@Override
public NumConst atan()
{
return Num.make(Math.atan(value()));
}
@Override
public NumConst signum()
{
return Num.make(Math.signum(value()));
}
@Override
public NumConst average(double other)
{
return Num.make((value() + other) / 2);
}
public NumConst average(NumConst other)
{
return super.average(other).freeze();
}
@Override
public NumConst round()
{
return Num.make(Math.round(value()));
}
@Override
public NumConst ceil()
{
return Num.make(Math.ceil(value()));
}
@Override
public NumConst floor()
{
return Num.make(Math.floor(value()));
}
@Override
public NumConst half()
{
return mul(0.5);
}
}

@ -1,49 +0,0 @@
package mightypork.gamecore.util.math.constraints.num;
import java.util.ArrayList;
import java.util.List;
/**
* Expandable sum of multiple numbers
*
* @author Ondřej Hruška (MightyPork)
*/
public class NumSum extends Num {
private final List<Num> summands = new ArrayList<>();
@Override
public double value()
{
double v = 0;
for (final Num n : summands) {
if (n != null) v += n.value();
}
return v;
}
/**
* Add a number to the sum
*
* @param summand added number
*/
public void addSummand(Num summand)
{
summands.add(summand);
}
/**
* Add a number to the sum
*
* @param summand added number
*/
public void addSummand(double summand)
{
summands.add(Num.make(summand));
}
}

@ -1,84 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.caching;
import mightypork.gamecore.util.math.constraints.ConstraintCache;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.num.mutable.NumVar;
import mightypork.gamecore.util.math.constraints.num.proxy.NumAdapter;
/**
* <p>
* A Num cache.
* </p>
* <p>
* Values are held in a caching VectVar, and digest caching is enabled by
* default.
* </p>
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class AbstractNumCache extends NumAdapter implements ConstraintCache<Num> {
private final NumVar cache = Num.makeVar();
private boolean inited = false;
private boolean cachingEnabled = true;
public AbstractNumCache()
{
enableDigestCaching(true); // it changes only on poll
}
@Override
protected final Num getSource()
{
if (!inited) markDigestDirty();
return (cachingEnabled ? cache : getCacheSource());
}
@Override
public final void poll()
{
inited = true;
// poll source
final Num source = getCacheSource();
source.markDigestDirty(); // poll cached
// store source value
cache.setTo(source);
// mark my digest dirty
markDigestDirty();
onConstraintChanged();
}
@Override
public abstract void onConstraintChanged();
@Override
public abstract Num getCacheSource();
@Override
public final void enableCaching(boolean yes)
{
cachingEnabled = yes;
enableDigestCaching(yes);
}
@Override
public final boolean isCachingEnabled()
{
return cachingEnabled;
}
}

@ -1,37 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.caching;
import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.constraints.num.Num;
/**
* Num cache implementation
*
* @author Ondřej Hruška (MightyPork)
*/
public class NumCache extends AbstractNumCache {
private final Num source;
public NumCache(Num source)
{
this.source = source;
}
@Override
public final Num getCacheSource()
{
return source;
}
@Override
@DefaultImpl
public void onConstraintChanged()
{
}
}

@ -1,23 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.caching;
import mightypork.gamecore.util.math.constraints.num.Num;
public class NumDigest {
public final double value;
public NumDigest(Num num)
{
this.value = num.value();
}
@Override
public String toString()
{
return String.format("Num(%.1f)", value);
}
}

@ -1,41 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.mutable;
import mightypork.gamecore.util.math.constraints.num.Num;
/**
* Mutable numeric variable
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class NumMutable extends Num {
/**
* Assign a value
*
* @param value new value
*/
public abstract void setTo(double value);
/**
* Assign a value
*
* @param value new value
*/
public void setTo(Num value)
{
setTo(value.value());
}
/**
* Set to zero
*/
public void reset()
{
setTo(0);
}
}

@ -1,42 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.mutable;
import mightypork.gamecore.util.math.constraints.num.Num;
/**
* Mutable numeric variable.
*
* @author Ondřej Hruška (MightyPork)
*/
public class NumVar extends NumMutable {
private double value;
public NumVar(Num value)
{
this(value.value());
}
public NumVar(double value)
{
this.value = value;
}
@Override
public double value()
{
return value;
}
@Override
public void setTo(double value)
{
this.value = value;
}
}

@ -1,18 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.proxy;
import mightypork.gamecore.util.math.constraints.num.Num;
public abstract class NumAdapter extends Num {
protected abstract Num getSource();
@Override
public double value()
{
return getSource().value();
}
}

@ -1,19 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.proxy;
import mightypork.gamecore.util.math.constraints.num.Num;
/**
* Numeric constraint
*
* @author Ondřej Hruška (MightyPork)
*/
public interface NumBound {
/**
* @return current value
*/
Num getNum();
}

@ -1,36 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.proxy;
import mightypork.gamecore.util.math.constraints.num.Num;
public class NumBoundAdapter extends NumAdapter implements PluggableNumBound {
private NumBound backing = null;
public NumBoundAdapter()
{
}
public NumBoundAdapter(NumBound bound)
{
backing = bound;
}
@Override
public void setNum(NumBound num)
{
this.backing = num;
}
@Override
protected Num getSource()
{
return backing.getNum();
}
}

@ -1,24 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.proxy;
import mightypork.gamecore.util.math.constraints.num.Num;
public class NumProxy extends NumAdapter {
private final Num source;
public NumProxy(Num source)
{
this.source = source;
}
@Override
protected Num getSource()
{
return source;
}
}

@ -1,16 +0,0 @@
package mightypork.gamecore.util.math.constraints.num.proxy;
/**
* Pluggable numeric constraint
*
* @author Ondřej Hruška (MightyPork)
*/
public interface PluggableNumBound extends NumBound {
/**
* @param num bound to set
*/
abstract void setNum(NumBound num);
}

File diff suppressed because it is too large Load Diff

@ -1,486 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect;
import mightypork.gamecore.util.math.constraints.num.NumConst;
import mightypork.gamecore.util.math.constraints.rect.caching.RectDigest;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.VectConst;
/**
* Rectangle with constant bounds, that can never change.<br>
* It's arranged so that operations with constant arguments yield constant
* results.
*
* @author Ondřej Hruška (MightyPork)
*/
public class RectConst extends Rect {
private final VectConst pos;
private final VectConst size;
// cached with lazy loading
private NumConst v_b;
private NumConst v_r;
private VectConst v_br;
private VectConst v_tc;
private VectConst v_tr;
private VectConst v_cl;
private VectConst v_c;
private VectConst v_cr;
private VectConst v_bl;
private VectConst v_bc;
private RectConst v_round;
private RectConst v_edge_l;
private RectConst v_edge_r;
private RectConst v_edge_t;
private RectConst v_edge_b;
private RectDigest digest;
private RectConst v_floor;
private RectConst v_ceil;
private RectConst v_axis_v;
private RectConst v_axis_h;
/**
* Create at given origin, with given size.
*
* @param x
* @param y
* @param width
* @param height
*/
RectConst(double x, double y, double width, double height)
{
this.pos = Vect.make(x, y);
this.size = Vect.make(width, height);
}
/**
* Create at given origin, with given size.
*
* @param origin
* @param size
*/
RectConst(Vect origin, Vect size)
{
this.pos = origin.freeze();
this.size = size.freeze();
}
/**
* Create at given origin, with given size.
*
* @param another other coord
*/
RectConst(Rect another)
{
this.pos = another.origin().freeze();
this.size = another.size().freeze();
}
/**
* @deprecated it's useless to copy a constant
*/
@Override
@Deprecated
public RectConst freeze()
{
return this; // already constant
}
@Override
public RectDigest digest()
{
return (digest != null) ? digest : (digest = super.digest());
}
@Override
public VectConst origin()
{
return pos;
}
@Override
public VectConst size()
{
return size;
}
@Override
public RectConst move(Vect move)
{
return move(move.x(), move.y());
}
@Override
public RectConst move(double x, double y)
{
return Rect.make(pos.add(x, y), size);
}
public RectConst move(NumConst x, NumConst y)
{
return super.move(x, y).freeze();
}
@Override
public RectConst shrink(double left, double right, double top, double bottom)
{
return super.shrink(left, right, top, bottom).freeze();
}
@Override
public RectConst grow(double left, double right, double top, double bottom)
{
return super.grow(left, right, top, bottom).freeze();
}
@Override
public RectConst round()
{
return (v_round != null) ? v_round : (v_round = Rect.make(pos.round(), size.round()));
}
@Override
public RectConst floor()
{
return (v_floor != null) ? v_floor : (v_floor = Rect.make(pos.floor(), size.floor()));
}
@Override
public RectConst ceil()
{
return (v_ceil != null) ? v_ceil : (v_ceil = Rect.make(pos.ceil(), size.ceil()));
}
@Override
public NumConst x()
{
return pos.xn();
}
@Override
public NumConst y()
{
return pos.yn();
}
@Override
public NumConst width()
{
return size.xn();
}
@Override
public NumConst height()
{
return size.yn();
}
@Override
public NumConst left()
{
return pos.xn();
}
@Override
public NumConst right()
{
return (v_r != null) ? v_r : (v_r = super.right().freeze());
}
@Override
public NumConst top()
{
return pos.yn();
}
@Override
public NumConst bottom()
{
return (v_b != null) ? v_b : (v_b = super.bottom().freeze());
}
@Override
public VectConst topLeft()
{
return pos;
}
@Override
public VectConst topCenter()
{
return (v_tc != null) ? v_tc : (v_tc = super.topCenter().freeze());
}
@Override
public VectConst topRight()
{
return (v_tr != null) ? v_tr : (v_tr = super.topRight().freeze());
}
@Override
public VectConst centerLeft()
{
return (v_cl != null) ? v_cl : (v_cl = super.centerLeft().freeze());
}
@Override
public VectConst center()
{
return (v_c != null) ? v_c : (v_c = super.center().freeze());
}
@Override
public VectConst centerRight()
{
return (v_cr != null) ? v_cr : (v_cr = super.centerRight().freeze());
}
@Override
public VectConst bottomLeft()
{
return (v_bl != null) ? v_bl : (v_bl = super.bottomLeft().freeze());
}
@Override
public VectConst bottomCenter()
{
return (v_bc != null) ? v_bc : (v_bc = super.bottomCenter().freeze());
}
@Override
public VectConst bottomRight()
{
return (v_br != null) ? v_br : (v_br = super.bottomRight().freeze());
}
@Override
public RectConst leftEdge()
{
return (v_edge_l != null) ? v_edge_l : (v_edge_l = super.leftEdge().freeze());
}
@Override
public RectConst rightEdge()
{
return (v_edge_r != null) ? v_edge_r : (v_edge_r = super.rightEdge().freeze());
}
@Override
public RectConst topEdge()
{
return (v_edge_t != null) ? v_edge_t : (v_edge_t = super.topEdge().freeze());
}
@Override
public RectConst bottomEdge()
{
return (v_edge_b != null) ? v_edge_b : (v_edge_b = super.bottomEdge().freeze());
}
@Override
public Rect axisV()
{
return (v_axis_v != null) ? v_axis_v : (v_axis_v = super.axisV().freeze());
}
@Override
public Rect axisH()
{
return (v_axis_h != null) ? v_axis_h : (v_axis_h = super.axisH().freeze());
}
@Override
public Rect shrink(Vect shrink)
{
return super.shrink(shrink);
}
@Override
public RectConst shrink(double x, double y)
{
return super.shrink(x, y).freeze();
}
public RectConst shrink(NumConst left, NumConst right, NumConst top, NumConst bottom)
{
return super.shrink(left, right, top, bottom).freeze();
}
public RectConst grow(NumConst left, NumConst right, NumConst top, NumConst bottom)
{
return super.grow(left, right, top, bottom).freeze();
}
@Override
public RectConst shrinkLeft(double shrink)
{
return super.shrinkLeft(shrink).freeze();
}
@Override
public RectConst shrinkRight(double shrink)
{
return super.shrinkRight(shrink).freeze();
}
@Override
public RectConst shrinkTop(double shrink)
{
return super.shrinkTop(shrink).freeze();
}
@Override
public RectConst shrinkBottom(double shrink)
{
return super.shrinkBottom(shrink).freeze();
}
@Override
public RectConst growLeft(double shrink)
{
return super.growLeft(shrink).freeze();
}
@Override
public RectConst growRight(double shrink)
{
return super.growRight(shrink).freeze();
}
@Override
public RectConst growUp(double shrink)
{
return super.growUp(shrink).freeze();
}
@Override
public RectConst growDown(double shrink)
{
return super.growDown(shrink).freeze();
}
public RectConst shrinkLeft(NumConst shrink)
{
return super.shrinkLeft(shrink).freeze();
}
public RectConst shrinkRight(NumConst shrink)
{
return super.shrinkRight(shrink).freeze();
}
public RectConst shrinkTop(NumConst shrink)
{
return super.shrinkTop(shrink).freeze();
}
public RectConst shrinkBottom(NumConst shrink)
{
return super.shrinkBottom(shrink).freeze();
}
public RectConst growLeft(NumConst shrink)
{
return super.growLeft(shrink).freeze();
}
public RectConst growRight(NumConst shrink)
{
return super.growRight(shrink).freeze();
}
public RectConst growUp(NumConst shrink)
{
return super.growUp(shrink).freeze();
}
public RectConst growBottom(NumConst shrink)
{
return super.growDown(shrink).freeze();
}
public RectConst centerTo(VectConst point)
{
return super.centerTo(point).freeze();
}
public RectConst centerTo(RectConst parent)
{
return super.centerTo(parent).freeze();
}
public RectConst shrink(NumConst x, NumConst y)
{
return super.shrink(x, y).freeze();
}
public RectConst grow(NumConst x, NumConst y)
{
return super.grow(x, y).freeze();
}
}

@ -1,130 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.builders;
import mightypork.gamecore.logging.Log;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectProxy;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Utility for cutting rect into evenly sized cells.
*
* @author Ondřej Hruška (MightyPork)
*/
public class TiledRect extends RectProxy {
final private int tilesY;
final private int tilesX;
final private Num perRow;
final private Num perCol;
/** Left top tile */
private Rect aTile;
public TiledRect(Rect source, int horizontal, int vertical)
{
super(source);
this.tilesX = horizontal;
this.tilesY = vertical;
this.perRow = height().div(vertical);
this.perCol = width().div(horizontal);
this.aTile = Rect.make(origin(), perCol, perRow);
}
/**
* Set tile overlap. Applies only to tile, not span.
*
* @param overlap how far to overlap to neighbouring tiles on all sides
*/
public void setOverlap(double overlap)
{
aTile = aTile.grow(overlap);
}
/**
* Get a tile.
*
* @param x x position
* @param y y position
* @return tile
* @throws IndexOutOfBoundsException when invalid index is specified.
*/
public Rect tile(int x, int y)
{
if (x >= tilesX || x < 0) {
throw new IndexOutOfBoundsException("X coordinate out fo range: " + x);
}
if (y >= tilesY || y < 0) {
throw new IndexOutOfBoundsException("Y coordinate out of range: " + y);
}
return aTile.move(perCol.mul(x), perRow.mul(y));
}
/**
* Get a span (tile spanning across multiple cells)
*
* @param x x start position
* @param y y start position
* @param size_x horizontal size (columns)
* @param size_y vertical size (rows)
* @return tile the tile
* @throws IndexOutOfBoundsException when invalid index is specified.
*/
public Rect span(int x, int y, int size_x, int size_y)
{
final int x_to = x + size_x - 1;
final int y_to = y + size_y - 1;
if (size_x <= 0 || size_y <= 0) {
Log.w("Size must be > 0.", new IllegalAccessException());
}
if (x >= tilesX || x < 0 || x_to >= tilesX || x_to < 0) {
Log.w("X coordinate(s) out of range.", new IllegalAccessException());
}
if (y >= tilesY || y < 0 || y_to >= tilesY || y_to < 0) {
Log.w("Y coordinate(s) out of range.", new IllegalAccessException());
}
final Vect orig = origin().add(perCol.mul(x), perRow.mul(y));
return Rect.make(orig, perCol.mul(size_x), perRow.mul(size_y));
}
/**
* Get n-th column
*
* @param n column index
* @return the column tile
* @throws IndexOutOfBoundsException when invalid index is specified.
*/
public Rect column(int n)
{
return tile(n, 0);
}
/**
* Get n-th row
*
* @param n row index
* @return the row rect
* @throws IndexOutOfBoundsException when invalid index is specified.
*/
public Rect row(int n)
{
return tile(0, n);
}
}

@ -1,75 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.caching;
import mightypork.gamecore.util.math.constraints.ConstraintCache;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.rect.mutable.RectVar;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectAdapter;
/**
* <p>
* A rect cache.
* </p>
* <p>
* Values are held in a caching VectVar, and digest caching is enabled by
* default.
* </p>
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class AbstractRectCache extends RectAdapter implements ConstraintCache<Rect> {
private final RectVar cache = Rect.makeVar();
private boolean inited = false;
private boolean cachingEnabled = true;
public AbstractRectCache()
{
enableDigestCaching(true); // it changes only on poll
}
@Override
protected final Rect getSource()
{
if (!inited) poll();
return (cachingEnabled ? cache : getCacheSource());
}
@Override
public final void poll()
{
inited = true;
// poll source
final Rect source = getCacheSource();
source.markDigestDirty(); // poll cached
// store source value
cache.setTo(source);
markDigestDirty();
onConstraintChanged();
}
@Override
public final void enableCaching(boolean yes)
{
cachingEnabled = yes;
enableDigestCaching(yes);
}
@Override
public final boolean isCachingEnabled()
{
return cachingEnabled;
}
}

@ -1,37 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.caching;
import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.constraints.rect.Rect;
/**
* Rect cache implementation
*
* @author Ondřej Hruška (MightyPork)
*/
public class RectCache extends AbstractRectCache {
private final Rect source;
public RectCache(Rect source)
{
this.source = source;
}
@Override
public final Rect getCacheSource()
{
return source;
}
@Override
@DefaultImpl
public void onConstraintChanged()
{
}
}

@ -1,41 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.caching;
import mightypork.gamecore.util.math.constraints.rect.Rect;
public class RectDigest {
public final double x;
public final double y;
public final double width;
public final double height;
public final double left;
public final double right;
public final double top;
public final double bottom;
public RectDigest(Rect rect)
{
this.x = rect.origin().x();
this.y = rect.origin().y();
this.width = rect.size().x();
this.height = rect.size().y();
this.left = x;
this.right = x + width;
this.top = y;
this.bottom = y + height;
}
@Override
public String toString()
{
return String
.format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom);
}
}

@ -1,91 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.mutable;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Mutable rectangle; operations change it's state.
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class RectMutable extends Rect {
/**
* Set to other rect's coordinates
*
* @param rect other rect
*/
public void setTo(Rect rect)
{
setTo(rect.origin(), rect.size());
}
/**
* Set to given size and position
*
* @param origin new origin
* @param width new width
* @param height new height
*/
public void setTo(Vect origin, double width, double height)
{
setTo(origin, Vect.make(width, height));
}
/**
* Set to given size and position
*
* @param x origin.x
* @param y origin.y
* @param width new width
* @param height new height
*/
public void setTo(double x, double y, double width, double height)
{
setTo(Vect.make(x, y), Vect.make(width, height));
}
/**
* Set to given size and position
*
* @param origin new origin
* @param size new size
*/
public void setTo(Vect origin, Vect size)
{
setOrigin(origin);
setSize(size);
}
/**
* Set to zero
*/
public void reset()
{
setTo(Vect.ZERO, Vect.ZERO);
}
public abstract void setOrigin(double x, double y);
public void setOrigin(Vect origin)
{
setOrigin(origin.x(), origin.y());
}
public void setSize(Vect size)
{
setSize(size.x(), size.y());
}
public abstract void setSize(double x, double y);
}

@ -1,55 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.mutable;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar;
public class RectVar extends RectMutable {
final VectVar pos = Vect.makeVar();
final VectVar size = Vect.makeVar();
/**
* Create at given origin, with given size.
*
* @param x
* @param y
* @param width
* @param height
*/
public RectVar(double x, double y, double width, double height)
{
this.pos.setTo(x, y);
this.size.setTo(width, height);
}
@Override
public Vect origin()
{
return pos;
}
@Override
public Vect size()
{
return size;
}
@Override
public void setOrigin(double x, double y)
{
this.pos.setTo(x, y);
}
@Override
public void setSize(double x, double y)
{
this.size.setTo(x, y);
}
}

@ -1,16 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.proxy;
/**
* Pluggable rect bound
*
* @author Ondřej Hruška (MightyPork)
*/
public interface PluggableRectBound extends RectBound {
/**
* @param rect context to set
*/
abstract void setRect(RectBound rect);
}

@ -1,58 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.proxy;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter;
/**
* Rect proxy with abstract method for plugging in / generating rect
* dynamically.
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class RectAdapter extends Rect {
// adapters are needed in case the vect returned from source changes
// (is replaced). This way, references to origin and rect will stay intact.
private final VectAdapter originAdapter = new VectAdapter() {
@Override
protected Vect getSource()
{
return RectAdapter.this.getSource().origin();
}
};
private final VectAdapter sizeAdapter = new VectAdapter() {
@Override
protected Vect getSource()
{
return RectAdapter.this.getSource().size();
}
};
/**
* @return the proxied coord
*/
protected abstract Rect getSource();
@Override
public Vect origin()
{
return originAdapter;
}
@Override
public Vect size()
{
return sizeAdapter;
}
}

@ -1,18 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.proxy;
import mightypork.gamecore.util.math.constraints.rect.Rect;
/**
* Rect constraint (ie. region)
*
* @author Ondřej Hruška (MightyPork)
*/
public interface RectBound {
/**
* @return rect region
*/
Rect getRect();
}

@ -1,41 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.proxy;
import mightypork.gamecore.util.math.constraints.rect.Rect;
/**
* Pluggable rect bound adapter
*
* @author Ondřej Hruška (MightyPork)
*/
public class RectBoundAdapter extends RectAdapter implements PluggableRectBound {
private RectBound backing = null;
public RectBoundAdapter()
{
}
public RectBoundAdapter(RectBound bound)
{
backing = bound;
}
@Override
public void setRect(RectBound rect)
{
this.backing = rect;
}
@Override
public Rect getSource()
{
return backing.getRect();
}
}

@ -1,24 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.proxy;
import mightypork.gamecore.util.math.constraints.rect.Rect;
public class RectProxy extends RectAdapter {
private final Rect source;
public RectProxy(Rect source)
{
this.source = source;
}
@Override
protected Rect getSource()
{
return source;
}
}

@ -1,39 +0,0 @@
package mightypork.gamecore.util.math.constraints.rect.proxy;
import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Rect made of two {@link Vect}s
*
* @author Ondřej Hruška (MightyPork)
*/
public class RectVectAdapter extends Rect {
private final Vect origin;
private final Vect size;
public RectVectAdapter(Vect origin, Vect size)
{
this.origin = origin;
this.size = size;
}
@Override
public Vect origin()
{
return origin;
}
@Override
public Vect size()
{
return size;
}
}

File diff suppressed because it is too large Load Diff

@ -1,375 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.num.NumConst;
import mightypork.gamecore.util.math.constraints.rect.RectConst;
import mightypork.gamecore.util.math.constraints.vect.caching.VectDigest;
/**
* Coordinate with immutable numeric values.<br>
* This coordinate is guaranteed to never change, as opposed to view.<br>
* It's arranged so that operations with constant arguments yield constant
* results.
*
* @author Ondřej Hruška (MightyPork)
*/
public final class VectConst extends Vect {
private final double x, y, z;
// non-parametric operations are cached using lazy load.
private NumConst v_size;
private VectConst v_neg;
private VectConst v_ceil;
private VectConst v_floor;
private VectConst v_round;
private VectConst v_half;
private VectConst v_abs;
private NumConst v_xc;
private NumConst v_yc;
private NumConst v_zc;
private VectDigest digest;
VectConst(Vect other)
{
this(other.x(), other.y(), other.z());
}
VectConst(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
@Override
public double x()
{
return x;
}
@Override
public double y()
{
return y;
}
@Override
public double z()
{
return z;
}
/**
* @return X constraint
*/
@Override
public final NumConst xn()
{
return (v_xc != null) ? v_xc : (v_xc = Num.make(this.x));
}
/**
* @return Y constraint
*/
@Override
public final NumConst yn()
{
return (v_yc != null) ? v_yc : (v_yc = Num.make(this.y));
}
/**
* @return Z constraint
*/
@Override
public final NumConst zn()
{
return (v_zc != null) ? v_zc : (v_zc = Num.make(this.z));
}
/**
* @deprecated it's useless to copy a constant
*/
@Override
@Deprecated
public VectConst freeze()
{
return this; // it's constant already
}
@Override
public VectDigest digest()
{
return (digest != null) ? digest : (digest = super.digest());
}
@Override
public VectConst abs()
{
return (v_abs != null) ? v_abs : (v_abs = super.abs().freeze());
}
@Override
public VectConst add(double x, double y)
{
return super.add(x, y).freeze();
}
@Override
public VectConst add(double x, double y, double z)
{
return super.add(x, y, z).freeze();
}
@Override
public VectConst half()
{
return (v_half != null) ? v_half : (v_half = super.half().freeze());
}
@Override
public VectConst mul(double d)
{
return super.mul(d).freeze();
}
@Override
public VectConst mul(double x, double y)
{
return super.mul(x, y).freeze();
}
@Override
public VectConst mul(double x, double y, double z)
{
return super.mul(x, y, z).freeze();
}
@Override
public VectConst round()
{
return (v_round != null) ? v_round : (v_round = super.round().freeze());
}
@Override
public VectConst floor()
{
return (v_floor != null) ? v_floor : (v_floor = super.floor().freeze());
}
@Override
public VectConst ceil()
{
if (v_ceil != null) return v_ceil;
return v_ceil = super.ceil().freeze();
}
@Override
public VectConst sub(double x, double y)
{
return super.sub(x, y).freeze();
}
@Override
public VectConst sub(double x, double y, double z)
{
return super.sub(x, y, z).freeze();
}
@Override
public VectConst neg()
{
return (v_neg != null) ? v_neg : (v_neg = super.neg().freeze());
}
@Override
public VectConst norm(double size)
{
return super.norm(size).freeze();
}
@Override
public NumConst size()
{
return (v_size != null) ? v_size : (v_size = super.size().freeze());
}
@Override
public VectConst withX(double x)
{
return super.withX(x).freeze();
}
@Override
public VectConst withY(double y)
{
return super.withY(y).freeze();
}
@Override
public VectConst withZ(double z)
{
return super.withZ(z).freeze();
}
public VectConst withX(NumConst x)
{
return super.withX(x).freeze();
}
public VectConst withY(NumConst y)
{
return super.withY(y).freeze();
}
public VectConst withZ(NumConst z)
{
return super.withZ(z).freeze();
}
public VectConst add(VectConst vec)
{
return super.add(vec).freeze();
}
public VectConst add(NumConst x, NumConst y)
{
return super.add(x, y).freeze();
}
public VectConst add(NumConst x, NumConst y, NumConst z)
{
return super.add(x, y, z).freeze();
}
public VectConst mul(VectConst vec)
{
return super.mul(vec).freeze();
}
public VectConst mul(NumConst d)
{
return super.mul(d).freeze();
}
public VectConst mul(NumConst x, NumConst y)
{
return super.mul(x, y).freeze();
}
public VectConst mul(NumConst x, NumConst y, NumConst z)
{
return super.mul(x, y, z).freeze();
}
public VectConst sub(VectConst vec)
{
return super.sub(vec).freeze();
}
public VectConst sub(NumConst x, NumConst y)
{
return super.sub(x, y).freeze();
}
public VectConst sub(NumConst x, NumConst y, NumConst z)
{
return super.sub(x, y, z).freeze();
}
public VectConst norm(NumConst size)
{
return super.norm(size).freeze();
}
public NumConst dist(VectConst point)
{
return super.dist(point).freeze();
}
public VectConst midTo(VectConst point)
{
return super.midTo(point).freeze();
}
public VectConst vectTo(VectConst point)
{
return super.vectTo(point).freeze();
}
public NumConst dot(VectConst vec)
{
return super.dot(vec).freeze();
}
public VectConst cross(VectConst vec)
{
return super.cross(vec).freeze();
}
@Override
public RectConst expand(double left, double right, double top, double bottom)
{
return super.expand(left, right, top, bottom).freeze();
}
public RectConst expand(NumConst left, NumConst right, NumConst top, NumConst bottom)
{
return super.expand(left, right, top, bottom).freeze();
}
}

@ -1,24 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect;
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter;
public class VectProxy extends VectAdapter {
private final Vect source;
public VectProxy(Vect source)
{
this.source = source;
}
@Override
protected Vect getSource()
{
return source;
}
}

@ -1,75 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.caching;
import mightypork.gamecore.util.math.constraints.ConstraintCache;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar;
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter;
/**
* <p>
* A vect cache.
* </p>
* <p>
* Values are held in a caching VectVar, and digest caching is enabled by
* default.
* </p>
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class AbstractVectCache extends VectAdapter implements ConstraintCache<Vect> {
private final VectVar cache = Vect.makeVar();
private boolean inited = false;
private boolean cachingEnabled = true;
public AbstractVectCache()
{
enableDigestCaching(true); // it changes only on poll
}
@Override
protected final Vect getSource()
{
if (!inited) markDigestDirty();
return (cachingEnabled ? cache : getCacheSource());
}
@Override
public final void poll()
{
inited = true;
// poll source
final Vect source = getCacheSource();
source.markDigestDirty(); // poll cached
// store source value
cache.setTo(source);
markDigestDirty();
onConstraintChanged();
}
@Override
public final void enableCaching(boolean yes)
{
cachingEnabled = yes;
enableDigestCaching(yes);
}
@Override
public final boolean isCachingEnabled()
{
return cachingEnabled;
}
}

@ -1,37 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.caching;
import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Vect cache implementation
*
* @author Ondřej Hruška (MightyPork)
*/
public class VectCache extends AbstractVectCache {
private final Vect source;
public VectCache(Vect source)
{
this.source = source;
enableDigestCaching(true);
}
@Override
public Vect getCacheSource()
{
return source;
}
@Override
@DefaultImpl
public void onConstraintChanged()
{
}
}

@ -1,27 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.caching;
import mightypork.gamecore.util.math.constraints.vect.Vect;
public class VectDigest {
public final double x;
public final double y;
public final double z;
public VectDigest(Vect vect)
{
this.x = vect.x();
this.y = vect.y();
this.z = vect.z();
}
@Override
public String toString()
{
return String.format("Vect(%.1f, %.1f, %.1f)", x, y, z);
}
}

@ -1,80 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.mutable;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Mutable coord
*
* @author Ondřej Hruška (MightyPork)
*/
abstract class VectMutable extends Vect {
/**
* Set all to zeros.
*/
public void reset()
{
setTo(0, 0, 0);
}
/**
* Set coordinates to match other coord.
*
* @param copied coord whose coordinates are used
*/
public void setTo(Vect copied)
{
setTo(copied.x(), copied.y(), copied.z());
}
/**
* Set 2D coordinates.<br>
* Z is unchanged.
*
* @param x x coordinate
* @param y y coordinate
*/
public void setTo(double x, double y)
{
setX(x);
setY(y);
}
/**
* Set coordinates.
*
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
*/
public abstract void setTo(double x, double y, double z);
/**
* Set X coordinate.
*
* @param x x coordinate
*/
public abstract void setX(double x);
/**
* Set Y coordinate.
*
* @param y y coordinate
*/
public abstract void setY(double y);
/**
* Set Z coordinate.
*
* @param z z coordinate
*/
public abstract void setZ(double z);
}

@ -1,78 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.mutable;
/**
* Mutable coordinate.<br>
* All Vec methods (except copy) alter data values and return this instance.
*
* @author Ondřej Hruška (MightyPork)
*/
public class VectVar extends VectMutable {
private double x, y, z;
/**
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
*/
public VectVar(double x, double y, double z)
{
super();
this.x = x;
this.y = y;
this.z = z;
}
@Override
public double x()
{
return x;
}
@Override
public double y()
{
return y;
}
@Override
public double z()
{
return z;
}
@Override
public void setTo(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void setX(double x)
{
this.x = x;
}
@Override
public void setY(double y)
{
this.y = y;
}
@Override
public void setZ(double z)
{
this.z = z;
}
}

@ -1,16 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.proxy;
/**
* Pluggable vector constraint
*
* @author Ondřej Hruška (MightyPork)
*/
public interface PluggableVectBound extends VectBound {
/**
* @param num bound to set
*/
abstract void setVect(VectBound num);
}

@ -1,41 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.proxy;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Vect proxy with abstract method for plugging in / generating coordinates
* dynamically.
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class VectAdapter extends Vect {
/**
* @return the proxied coord
*/
protected abstract Vect getSource();
@Override
public double x()
{
return getSource().x();
}
@Override
public double y()
{
return getSource().y();
}
@Override
public double z()
{
return getSource().z();
}
}

@ -1,18 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.proxy;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Element holding a vector, used for constraint building.
*
* @author Ondřej Hruška (MightyPork)
*/
public interface VectBound {
/**
* @return the current vector.
*/
public Vect getVect();
}

@ -1,36 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.proxy;
import mightypork.gamecore.util.math.constraints.vect.Vect;
public class VectBoundAdapter extends VectAdapter implements PluggableVectBound {
private VectBound backing = null;
public VectBoundAdapter()
{
}
public VectBoundAdapter(VectBound bound)
{
backing = bound;
}
@Override
public void setVect(VectBound rect)
{
this.backing = rect;
}
@Override
protected Vect getSource()
{
return backing.getVect();
}
}

@ -1,57 +0,0 @@
package mightypork.gamecore.util.math.constraints.vect.proxy;
import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.num.proxy.NumBound;
import mightypork.gamecore.util.math.constraints.vect.Vect;
/**
* Coord view composed of given {@link NumBound}s, using their current values.
*
* @author Ondřej Hruška (MightyPork)
*/
public class VectNumAdapter extends Vect {
private final Num constrX;
private final Num constrY;
private final Num constrZ;
public VectNumAdapter(Num x, Num y, Num z)
{
this.constrX = x;
this.constrY = y;
this.constrZ = z;
}
public VectNumAdapter(Num x, Num y)
{
this.constrX = x;
this.constrY = y;
this.constrZ = Num.ZERO;
}
@Override
public double x()
{
return constrX.value();
}
@Override
public double y()
{
return constrY.value();
}
@Override
public double z()
{
return constrZ.value();
}
}

@ -2,7 +2,8 @@ package mightypork.gamecore.util.math.timing;
import mightypork.gamecore.gui.Enableable; import mightypork.gamecore.gui.Enableable;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; import mightypork.gamecore.util.math.timing.animation.AnimatorRewind;
import mightypork.gamecore.util.math.timing.animation.NumAnimated;
public abstract class TaskRepeater extends AnimatorRewind implements Runnable, Enableable { public abstract class TaskRepeater extends AnimatorRewind implements Runnable, Enableable {

@ -1,8 +1,8 @@
package mightypork.gamecore.util.math.timing; package mightypork.gamecore.util.math.timing;
import mightypork.gamecore.util.math.timing.animation.NumAnimated;
import mightypork.gamecore.eventbus.events.Updateable;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
/** /**

@ -1,4 +1,4 @@
package mightypork.gamecore.eventbus.events; package mightypork.gamecore.util.math.timing;
/** /**

@ -1,12 +1,12 @@
package mightypork.gamecore.util.math.timing; package mightypork.gamecore.util.math.timing.animation;
import mightypork.gamecore.eventbus.events.Updateable; import mightypork.dynmath.num.Num;
import mightypork.gamecore.util.annot.DefaultImpl; import mightypork.gamecore.util.annot.DefaultImpl;
import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.Calc;
import mightypork.gamecore.util.math.Easing; import mightypork.gamecore.util.math.Easing;
import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.gamecore.util.math.timing.Pauseable;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; import mightypork.gamecore.util.math.timing.Updateable;
public abstract class Animator extends Num implements Updateable, Pauseable { public abstract class Animator extends Num implements Updateable, Pauseable {

@ -1,8 +1,7 @@
package mightypork.gamecore.util.math.timing; package mightypork.gamecore.util.math.timing.animation;
import mightypork.gamecore.util.math.Easing; import mightypork.gamecore.util.math.Easing;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
/** /**

@ -1,8 +1,7 @@
package mightypork.gamecore.util.math.timing; package mightypork.gamecore.util.math.timing.animation;
import mightypork.gamecore.util.math.Easing; import mightypork.gamecore.util.math.Easing;
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated;
/** /**

@ -1,10 +1,11 @@
package mightypork.gamecore.util.math.constraints.num.mutable; package mightypork.gamecore.util.math.timing.animation;
import mightypork.gamecore.eventbus.events.Updateable; import mightypork.dynmath.num.mutable.NumMutable;
import mightypork.gamecore.util.math.Calc; import mightypork.gamecore.util.math.Calc;
import mightypork.gamecore.util.math.Easing; import mightypork.gamecore.util.math.Easing;
import mightypork.gamecore.util.math.timing.Pauseable; import mightypork.gamecore.util.math.timing.Pauseable;
import mightypork.gamecore.util.math.timing.Updateable;
/** /**

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save