refactoring, nicer structure but blank screen now. some bug in caching?
This commit is contained in:
@@ -13,7 +13,7 @@ import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
|
|||||||
import mightypork.gamecore.control.timing.Updateable;
|
import mightypork.gamecore.control.timing.Updateable;
|
||||||
import mightypork.utils.math.Calc.Buffers;
|
import mightypork.utils.math.Calc.Buffers;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectVar;
|
import mightypork.utils.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;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import mightypork.gamecore.audio.DeferredAudio;
|
|||||||
import mightypork.gamecore.audio.Volume;
|
import mightypork.gamecore.audio.Volume;
|
||||||
import mightypork.gamecore.control.timing.Pauseable;
|
import mightypork.gamecore.control.timing.Pauseable;
|
||||||
import mightypork.gamecore.control.timing.Updateable;
|
import mightypork.gamecore.control.timing.Updateable;
|
||||||
import mightypork.utils.math.constraints.num.NumAnimated;
|
import mightypork.utils.math.constraints.num.mutable.NumAnimated;
|
||||||
|
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import mightypork.gamecore.audio.SoundSystem;
|
|||||||
import mightypork.gamecore.control.bus.EventBus;
|
import mightypork.gamecore.control.bus.EventBus;
|
||||||
import mightypork.gamecore.control.bus.events.*;
|
import mightypork.gamecore.control.bus.events.*;
|
||||||
import mightypork.gamecore.control.interf.Destroyable;
|
import mightypork.gamecore.control.interf.Destroyable;
|
||||||
import mightypork.gamecore.control.timing.Pollable;
|
|
||||||
import mightypork.gamecore.control.timing.Updateable;
|
import mightypork.gamecore.control.timing.Updateable;
|
||||||
import mightypork.gamecore.gui.screens.ScreenRegistry;
|
import mightypork.gamecore.gui.screens.ScreenRegistry;
|
||||||
import mightypork.gamecore.input.InputSystem;
|
import mightypork.gamecore.input.InputSystem;
|
||||||
@@ -21,6 +20,7 @@ import mightypork.utils.annotations.DefaultImpl;
|
|||||||
import mightypork.utils.files.InstanceLock;
|
import mightypork.utils.files.InstanceLock;
|
||||||
import mightypork.utils.logging.Log;
|
import mightypork.utils.logging.Log;
|
||||||
import mightypork.utils.logging.LogWriter;
|
import mightypork.utils.logging.LogWriter;
|
||||||
|
import mightypork.utils.math.constraints.Pollable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package mightypork.gamecore.control.bus.events;
|
|||||||
|
|
||||||
|
|
||||||
import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
|
import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
|
||||||
import mightypork.gamecore.control.timing.Pollable;
|
import mightypork.utils.math.constraints.Pollable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package mightypork.gamecore.control.bus.events;
|
package mightypork.gamecore.control.bus.events;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ import mightypork.gamecore.control.bus.EventBus;
|
|||||||
import mightypork.gamecore.control.bus.clients.ClientHub;
|
import mightypork.gamecore.control.bus.clients.ClientHub;
|
||||||
import mightypork.gamecore.input.InputSystem;
|
import mightypork.gamecore.input.InputSystem;
|
||||||
import mightypork.gamecore.render.DisplaySystem;
|
import mightypork.gamecore.render.DisplaySystem;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class BusEnabledPainter extends SimplePainter implements ClientHub, Component, AppAccess {
|
public abstract class BusEnabledPainter extends SimplePainter implements ClientHub, Component, AppAccess {
|
||||||
|
|
||||||
private RectBound context;
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
|
|
||||||
@@ -27,21 +24,6 @@ public abstract class BusEnabledPainter extends SimplePainter implements ClientH
|
|||||||
this.subModule = new AppSubModule(app);
|
this.subModule = new AppSubModule(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRect(RectBound context)
|
|
||||||
{
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Rect getRect()
|
|
||||||
{
|
|
||||||
return context.getRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EventBus getEventBus()
|
public EventBus getEventBus()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import mightypork.gamecore.control.bus.clients.ToggleableClient;
|
|||||||
import mightypork.gamecore.control.interf.Enableable;
|
import mightypork.gamecore.control.interf.Enableable;
|
||||||
import mightypork.gamecore.gui.Hideable;
|
import mightypork.gamecore.gui.Hideable;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package mightypork.gamecore.gui.components;
|
package mightypork.gamecore.gui.components;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.rect.PluggableRectBound;
|
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.PluggableRectBound;
|
||||||
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ package mightypork.gamecore.gui.components;
|
|||||||
|
|
||||||
|
|
||||||
import mightypork.utils.annotations.DefaultImpl;
|
import mightypork.utils.annotations.DefaultImpl;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.*;
|
||||||
import mightypork.utils.math.constraints.rect.RectAdapter;
|
import mightypork.utils.math.constraints.rect.caching.AbstractRectCache;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.caching.RectCache;
|
||||||
import mightypork.utils.math.constraints.rect.RectBoundAdapter;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
import mightypork.utils.math.constraints.rect.RectCache;
|
import mightypork.utils.math.constraints.rect.proxy.RectBoundAdapter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +14,7 @@ import mightypork.utils.math.constraints.rect.RectCache;
|
|||||||
*
|
*
|
||||||
* @author MightyPork
|
* @author MightyPork
|
||||||
*/
|
*/
|
||||||
public abstract class SimplePainter extends RectAdapter implements PluggableRenderable {
|
public abstract class SimplePainter extends AbstractRectCache implements PluggableRenderable {
|
||||||
|
|
||||||
private RectCache source;
|
private RectCache source;
|
||||||
|
|
||||||
@@ -29,41 +29,27 @@ public abstract class SimplePainter extends RectAdapter implements PluggableRend
|
|||||||
@Override
|
@Override
|
||||||
public void setRect(RectBound rect)
|
public void setRect(RectBound rect)
|
||||||
{
|
{
|
||||||
System.out.println("SP set rect");
|
|
||||||
this.source = new RectBoundAdapter(rect).cached();
|
this.source = new RectBoundAdapter(rect).cached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rect getSource()
|
public Rect getCacheSource()
|
||||||
{
|
{
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Poll bounds
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public final void poll()
|
|
||||||
{
|
|
||||||
System.out.println("SP poll, source: "+source);
|
|
||||||
source.poll();
|
|
||||||
super.poll();
|
|
||||||
|
|
||||||
onPoll();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void render();
|
public abstract void render();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after painter was polled; contained constraints can now poll too.
|
* Called after constraint was changed; contained constraints can now poll too.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@DefaultImpl
|
@DefaultImpl
|
||||||
public void onPoll()
|
public void onChange()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import mightypork.gamecore.gui.components.BusEnabledPainter;
|
|||||||
import mightypork.gamecore.gui.components.PluggableRenderable;
|
import mightypork.gamecore.gui.components.PluggableRenderable;
|
||||||
import mightypork.gamecore.gui.components.Renderable;
|
import mightypork.gamecore.gui.components.Renderable;
|
||||||
import mightypork.gamecore.gui.components.SimplePainter;
|
import mightypork.gamecore.gui.components.SimplePainter;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package mightypork.gamecore.gui.components.layout;
|
|||||||
|
|
||||||
import mightypork.gamecore.control.AppAccess;
|
import mightypork.gamecore.control.AppAccess;
|
||||||
import mightypork.gamecore.gui.components.PluggableRenderable;
|
import mightypork.gamecore.gui.components.PluggableRenderable;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.builders.TiledRect;
|
||||||
import mightypork.utils.math.constraints.rect.TiledRect;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package mightypork.gamecore.gui.components.layout;
|
|||||||
|
|
||||||
import mightypork.gamecore.control.AppAccess;
|
import mightypork.gamecore.control.AppAccess;
|
||||||
import mightypork.gamecore.gui.components.PluggableRenderable;
|
import mightypork.gamecore.gui.components.PluggableRenderable;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.builders.TiledRect;
|
||||||
import mightypork.utils.math.constraints.rect.TiledRect;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import mightypork.gamecore.input.KeyStroke;
|
|||||||
import mightypork.gamecore.render.Render;
|
import mightypork.gamecore.render.Render;
|
||||||
import mightypork.utils.annotations.DefaultImpl;
|
import mightypork.utils.annotations.DefaultImpl;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import mightypork.gamecore.input.KeyBindingPool;
|
|||||||
import mightypork.gamecore.input.KeyStroke;
|
import mightypork.gamecore.input.KeyStroke;
|
||||||
import mightypork.utils.annotations.DefaultImpl;
|
import mightypork.utils.annotations.DefaultImpl;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import mightypork.gamecore.control.timing.Updateable;
|
|||||||
import mightypork.rogue.events.ActionRequest;
|
import mightypork.rogue.events.ActionRequest;
|
||||||
import mightypork.rogue.events.ActionRequest.RequestType;
|
import mightypork.rogue.events.ActionRequest.RequestType;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectVar;
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
|
|||||||
import mightypork.gamecore.control.timing.FpsMeter;
|
import mightypork.gamecore.control.timing.FpsMeter;
|
||||||
import mightypork.utils.logging.Log;
|
import mightypork.utils.logging.Log;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import mightypork.utils.files.FileUtils;
|
|||||||
import mightypork.utils.logging.Log;
|
import mightypork.utils.logging.Log;
|
||||||
import mightypork.utils.math.color.RGB;
|
import mightypork.utils.math.color.RGB;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectDigest;
|
import mightypork.utils.math.constraints.rect.caching.RectDigest;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectConst;
|
import mightypork.utils.math.constraints.vect.VectConst;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import mightypork.gamecore.render.fonts.FontRenderer.Align;
|
|||||||
import mightypork.gamecore.render.fonts.GLFont;
|
import mightypork.gamecore.render.fonts.GLFont;
|
||||||
import mightypork.rogue.Res;
|
import mightypork.rogue.Res;
|
||||||
import mightypork.utils.math.color.RGB;
|
import mightypork.utils.math.color.RGB;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.string.StringProvider;
|
import mightypork.utils.string.StringProvider;
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import mightypork.gamecore.render.Render;
|
|||||||
import mightypork.utils.math.Easing;
|
import mightypork.utils.math.Easing;
|
||||||
import mightypork.utils.math.color.RGB;
|
import mightypork.utils.math.color.RGB;
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumAnimated;
|
import mightypork.utils.math.constraints.num.mutable.NumAnimated;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectCache;
|
import mightypork.utils.math.constraints.rect.caching.RectCache;
|
||||||
|
|
||||||
|
|
||||||
public class BouncyBox extends SimplePainter implements Updateable {
|
public class BouncyBox extends SimplePainter implements Updateable {
|
||||||
@@ -64,7 +64,7 @@ public class BouncyBox extends SimplePainter implements Updateable {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPoll()
|
public void onChange()
|
||||||
{
|
{
|
||||||
box.poll();
|
box.poll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ import mightypork.rogue.Res;
|
|||||||
import mightypork.utils.math.Easing;
|
import mightypork.utils.math.Easing;
|
||||||
import mightypork.utils.math.color.RGB;
|
import mightypork.utils.math.color.RGB;
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumAnimated;
|
import mightypork.utils.math.constraints.num.mutable.NumAnimated;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectAnimated;
|
import mightypork.utils.math.constraints.vect.mutable.VectAnimated;
|
||||||
|
|
||||||
|
|
||||||
public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButtonEvent.Listener {
|
public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButtonEvent.Listener {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import mightypork.gamecore.gui.screens.Screen;
|
|||||||
import mightypork.gamecore.gui.screens.ScreenLayer;
|
import mightypork.gamecore.gui.screens.ScreenLayer;
|
||||||
import mightypork.gamecore.render.Render;
|
import mightypork.gamecore.render.Render;
|
||||||
import mightypork.utils.math.color.RGB;
|
import mightypork.utils.math.color.RGB;
|
||||||
import mightypork.utils.math.constraints.rect.RectBound;
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
|
|
||||||
|
|
||||||
public class LayerTestGradient extends ScreenLayer {
|
public class LayerTestGradient extends ScreenLayer {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package mightypork.test;
|
|||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectCache;
|
import mightypork.utils.math.constraints.vect.caching.VectCache;
|
||||||
import mightypork.utils.math.constraints.vect.VectVar;
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
|
||||||
|
|
||||||
public class TestConstCaching {
|
public class TestConstCaching {
|
||||||
@@ -23,7 +23,7 @@ public class TestConstCaching {
|
|||||||
System.out.println("cache = " + cache);
|
System.out.println("cache = " + cache);
|
||||||
System.out.println("cache digest = " + cache.digest());
|
System.out.println("cache digest = " + cache.digest());
|
||||||
System.out.println("\n-- cache.poll() --\n");
|
System.out.println("\n-- cache.poll() --\n");
|
||||||
cache.poll();
|
cache.markDigestDirty();
|
||||||
System.out.println("in = " + in);
|
System.out.println("in = " + in);
|
||||||
System.out.println("cache = " + cache);
|
System.out.println("cache = " + cache);
|
||||||
System.out.println("cache digest = " + cache.digest());
|
System.out.println("cache digest = " + cache.digest());
|
||||||
@@ -33,7 +33,7 @@ public class TestConstCaching {
|
|||||||
System.out.println("cache = " + cache);
|
System.out.println("cache = " + cache);
|
||||||
System.out.println("cache digest = " + cache.digest());
|
System.out.println("cache digest = " + cache.digest());
|
||||||
System.out.println("\n-- cache.poll() --\n");
|
System.out.println("\n-- cache.poll() --\n");
|
||||||
cache.poll();
|
cache.markDigestDirty();
|
||||||
System.out.println("cache = " + cache);
|
System.out.println("cache = " + cache);
|
||||||
System.out.println("cache digest = " + cache.digest());
|
System.out.println("cache digest = " + cache.digest());
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ package mightypork.test;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumVar;
|
import mightypork.utils.math.constraints.num.mutable.NumVar;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.rect.RectConst;
|
import mightypork.utils.math.constraints.rect.RectConst;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectConst;
|
import mightypork.utils.math.constraints.vect.VectConst;
|
||||||
import mightypork.utils.math.constraints.vect.VectVar;
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
|
||||||
|
|
||||||
public class TestConstr {
|
public class TestConstr {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package mightypork.test;
|
|||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumVar;
|
import mightypork.utils.math.constraints.num.mutable.NumVar;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectVar;
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
|
||||||
|
|
||||||
public class TestCoords {
|
public class TestCoords {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package mightypork.test;
|
|||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumVar;
|
import mightypork.utils.math.constraints.num.mutable.NumVar;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package mightypork.test;
|
|||||||
|
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectConst;
|
import mightypork.utils.math.constraints.vect.VectConst;
|
||||||
import mightypork.utils.math.constraints.vect.VectVar;
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
|
||||||
|
|
||||||
public class TestVec {
|
public class TestVec {
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package mightypork.utils.math.constraints;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constraint cache
|
||||||
|
*
|
||||||
|
* @author MightyPork
|
||||||
|
* @param <C> constraint type
|
||||||
|
*/
|
||||||
|
public interface ConstraintCache<C> extends Pollable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after the cache has changed value (and digest).
|
||||||
|
*/
|
||||||
|
void onChange();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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();
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package mightypork.utils.math.constraints;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parametrized implementation of a {@link Digestable}
|
||||||
|
*
|
||||||
|
* @author MightyPork
|
||||||
|
* @param <D> digest class
|
||||||
|
*/
|
||||||
|
public abstract class DigestCache<D> implements Digestable<D> {
|
||||||
|
|
||||||
|
private D digest;
|
||||||
|
private boolean enabled;
|
||||||
|
private boolean dirty;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final D digest()
|
||||||
|
{
|
||||||
|
if (enabled) {
|
||||||
|
if (dirty || digest == null) {
|
||||||
|
digest = createDigest();
|
||||||
|
dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return digest;
|
||||||
|
}
|
||||||
|
|
||||||
|
return createDigest();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return fresh new digest
|
||||||
|
*/
|
||||||
|
protected abstract D createDigest();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void enableDigestCaching(boolean yes)
|
||||||
|
{
|
||||||
|
enabled = yes;
|
||||||
|
markDigestDirty(); // mark dirty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isDigestCachingEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void markDigestDirty()
|
||||||
|
{
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
package mightypork.utils.math.constraints;
|
package mightypork.utils.math.constraints;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.gamecore.control.timing.Pollable;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Interface for constraints that support digests. Digest is a small data object
|
* Interface for constraints that support digests. Digest is a small data object
|
||||||
* with final fields, typically primitive, used for procesing (such as rendering
|
* with final fields, typically primitive, used for processing (such as
|
||||||
* or other very frequent operations).
|
* rendering or other very frequent operations).
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Taking a digest is expensive, so if it needs to be done often and the value
|
* Taking a digest is expensive, so if it needs to be done often and the value
|
||||||
@@ -16,15 +13,19 @@ import mightypork.gamecore.control.timing.Pollable;
|
|||||||
* resize), it's useful to cache the last digest and reuse it until such an
|
* resize), it's useful to cache the last digest and reuse it until such an
|
||||||
* event occurs again.
|
* event occurs again.
|
||||||
* </p>
|
* </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 MightyPork
|
* @author MightyPork
|
||||||
* @param <D> digest class
|
* @param <D> digest class
|
||||||
*/
|
*/
|
||||||
public interface Digestable<D> extends Pollable {
|
public interface Digestable<D> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take a digest. If digest caching is enabled and a digest is already
|
* Take a digest. If digest caching is enabled and the cached digest is
|
||||||
* cached, it should be reused instead of making a new one.
|
* marked as dirty, a new one should be made.
|
||||||
*
|
*
|
||||||
* @return digest
|
* @return digest
|
||||||
*/
|
*/
|
||||||
@@ -51,11 +52,10 @@ public interface Digestable<D> extends Pollable {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If digest caching is enabled, query for a new digest and store it in a
|
* If digest caching is enabled, mark current cached value as "dirty". Dirty
|
||||||
* cache variable. This method shall only be called when the constraint is
|
* digest should be re-created next time a value is requested.<br>
|
||||||
* expected to have changed.
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
void markDigestDirty();
|
||||||
void poll();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.gamecore.control.timing;
|
package mightypork.utils.math.constraints;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.gamecore.control.timing;
|
package mightypork.utils.math.constraints;
|
||||||
|
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@@ -3,7 +3,13 @@ package mightypork.utils.math.constraints.num;
|
|||||||
|
|
||||||
import mightypork.utils.annotations.FactoryMethod;
|
import mightypork.utils.annotations.FactoryMethod;
|
||||||
import mightypork.utils.math.Calc;
|
import mightypork.utils.math.Calc;
|
||||||
|
import mightypork.utils.math.constraints.DigestCache;
|
||||||
import mightypork.utils.math.constraints.Digestable;
|
import mightypork.utils.math.constraints.Digestable;
|
||||||
|
import mightypork.utils.math.constraints.num.caching.NumCache;
|
||||||
|
import mightypork.utils.math.constraints.num.caching.NumDigest;
|
||||||
|
import mightypork.utils.math.constraints.num.mutable.NumVar;
|
||||||
|
import mightypork.utils.math.constraints.num.proxy.NumBound;
|
||||||
|
import mightypork.utils.math.constraints.num.proxy.NumBoundAdapter;
|
||||||
|
|
||||||
|
|
||||||
public abstract class Num implements NumBound, Digestable<NumDigest> {
|
public abstract class Num implements NumBound, Digestable<NumDigest> {
|
||||||
@@ -62,9 +68,15 @@ public abstract class Num implements NumBound, Digestable<NumDigest> {
|
|||||||
private Num p_square;
|
private Num p_square;
|
||||||
private Num p_neg;
|
private Num p_neg;
|
||||||
private Num p_abs;
|
private Num p_abs;
|
||||||
private NumDigest lastDigest = null;
|
|
||||||
private boolean digestCachingEnabled = false;
|
private DigestCache<NumDigest> dc = new DigestCache<NumDigest>() {
|
||||||
private boolean digestDirty = true;
|
|
||||||
|
@Override
|
||||||
|
protected NumDigest createDigest()
|
||||||
|
{
|
||||||
|
return new NumDigest(Num.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public NumConst freeze()
|
public NumConst freeze()
|
||||||
@@ -94,38 +106,28 @@ public abstract class Num implements NumBound, Digestable<NumDigest> {
|
|||||||
@Override
|
@Override
|
||||||
public NumDigest digest()
|
public NumDigest digest()
|
||||||
{
|
{
|
||||||
if (digestCachingEnabled) {
|
return dc.digest();
|
||||||
if (digestDirty) {
|
|
||||||
lastDigest = new NumDigest(this);
|
|
||||||
digestDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastDigest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new NumDigest(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableDigestCaching(boolean yes)
|
public void enableDigestCaching(boolean yes)
|
||||||
{
|
{
|
||||||
digestCachingEnabled = yes;
|
dc.enableDigestCaching(yes);
|
||||||
digestDirty = true; // schedule update nest time digest() is called
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDigestCachingEnabled()
|
public boolean isDigestCachingEnabled()
|
||||||
{
|
{
|
||||||
return digestCachingEnabled;
|
return dc.isDigestCachingEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void poll()
|
public void markDigestDirty()
|
||||||
{
|
{
|
||||||
if (digestCachingEnabled) digestDirty = true;
|
dc.markDigestDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* A num cache.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* Values are held in a caching VectVar, and digest caching is enabled by
|
|
||||||
* default.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author MightyPork
|
|
||||||
*/
|
|
||||||
public class NumCache extends NumAdapter {
|
|
||||||
|
|
||||||
private final NumVar cache = Num.makeVar();
|
|
||||||
private final Num source;
|
|
||||||
private boolean inited = false;
|
|
||||||
|
|
||||||
|
|
||||||
public NumCache(Num source) {
|
|
||||||
this.source = source;
|
|
||||||
enableDigestCaching(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Num getSource()
|
|
||||||
{
|
|
||||||
if (!inited) poll();
|
|
||||||
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update cached value and cached digest (if digest caching is enabled)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void poll()
|
|
||||||
{
|
|
||||||
inited = true;
|
|
||||||
cache.setTo(source);
|
|
||||||
|
|
||||||
super.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.caching.NumDigest;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant number.<br>
|
* Constant number.<br>
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package mightypork.utils.math.constraints.num.caching;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.ConstraintCache;
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
import mightypork.utils.math.constraints.num.mutable.NumVar;
|
||||||
|
import mightypork.utils.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 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();
|
||||||
|
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract void onChange();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract Num getCacheSource();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void enableCaching(boolean yes)
|
||||||
|
{
|
||||||
|
cachingEnabled = yes;
|
||||||
|
enableDigestCaching(yes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isCachingEnabled()
|
||||||
|
{
|
||||||
|
return cachingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package mightypork.utils.math.constraints.num.caching;
|
||||||
|
|
||||||
|
import mightypork.utils.annotations.DefaultImpl;
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Num cache implementation
|
||||||
|
*
|
||||||
|
* @author 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 onChange()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.caching;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
public class NumDigest {
|
public class NumDigest {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.mutable;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.gamecore.control.timing.Pauseable;
|
import mightypork.gamecore.control.timing.Pauseable;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.mutable;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.Calc;
|
import mightypork.utils.math.Calc;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.mutable;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.Calc;
|
import mightypork.utils.math.Calc;
|
||||||
+4
-2
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.mutable;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +25,7 @@ public abstract class NumMutable extends Num {
|
|||||||
*/
|
*/
|
||||||
public void setTo(Num value)
|
public void setTo(Num value)
|
||||||
{
|
{
|
||||||
setTo(value);
|
setTo(value.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.mutable;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
public abstract class NumAdapter extends Num {
|
public abstract class NumAdapter extends Num {
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
public class NumBoundAdapter extends NumAdapter implements PluggableNumBound {
|
public class NumBoundAdapter extends NumAdapter implements PluggableNumBound {
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
|
||||||
|
|
||||||
public class NumProxy extends NumAdapter {
|
public class NumProxy extends NumAdapter {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.utils.math.constraints.num;
|
package mightypork.utils.math.constraints.num.proxy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2,9 +2,17 @@ package mightypork.utils.math.constraints.rect;
|
|||||||
|
|
||||||
|
|
||||||
import mightypork.utils.annotations.FactoryMethod;
|
import mightypork.utils.annotations.FactoryMethod;
|
||||||
|
import mightypork.utils.math.constraints.DigestCache;
|
||||||
import mightypork.utils.math.constraints.Digestable;
|
import mightypork.utils.math.constraints.Digestable;
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumConst;
|
import mightypork.utils.math.constraints.num.NumConst;
|
||||||
|
import mightypork.utils.math.constraints.rect.builders.TiledRect;
|
||||||
|
import mightypork.utils.math.constraints.rect.caching.RectCache;
|
||||||
|
import mightypork.utils.math.constraints.rect.caching.RectDigest;
|
||||||
|
import mightypork.utils.math.constraints.rect.mutable.RectVar;
|
||||||
|
import mightypork.utils.math.constraints.rect.proxy.RectBound;
|
||||||
|
import mightypork.utils.math.constraints.rect.proxy.RectBoundAdapter;
|
||||||
|
import mightypork.utils.math.constraints.rect.proxy.RectVectAdapter;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectConst;
|
import mightypork.utils.math.constraints.vect.VectConst;
|
||||||
|
|
||||||
@@ -159,9 +167,14 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
|
|||||||
private Rect p_edge_t;
|
private Rect p_edge_t;
|
||||||
private Rect p_edge_b;
|
private Rect p_edge_b;
|
||||||
|
|
||||||
private RectDigest lastDigest = null;
|
private DigestCache<RectDigest> dc = new DigestCache<RectDigest>() {
|
||||||
private boolean digestCachingEnabled = false;
|
|
||||||
private boolean digestDirty = true; // digest is null
|
@Override
|
||||||
|
protected RectDigest createDigest()
|
||||||
|
{
|
||||||
|
return new RectDigest(Rect.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,38 +204,28 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
|
|||||||
@Override
|
@Override
|
||||||
public RectDigest digest()
|
public RectDigest digest()
|
||||||
{
|
{
|
||||||
if (digestCachingEnabled) {
|
return dc.digest();
|
||||||
if (digestDirty) {
|
|
||||||
lastDigest = new RectDigest(this);
|
|
||||||
digestDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastDigest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RectDigest(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableDigestCaching(boolean yes)
|
public void enableDigestCaching(boolean yes)
|
||||||
{
|
{
|
||||||
digestCachingEnabled = yes;
|
dc.enableDigestCaching(yes);
|
||||||
digestDirty = true; // schedule update nest time digest() is called
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDigestCachingEnabled()
|
public boolean isDigestCachingEnabled()
|
||||||
{
|
{
|
||||||
return digestCachingEnabled;
|
return dc.isDigestCachingEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void poll()
|
public void markDigestDirty()
|
||||||
{
|
{
|
||||||
if (digestCachingEnabled) digestDirty = true;
|
dc.markDigestDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* A rect cache.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* Values are held in a caching VectVar, and digest caching is enabled by
|
|
||||||
* default.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author MightyPork
|
|
||||||
*/
|
|
||||||
public class RectCache extends RectAdapter {
|
|
||||||
|
|
||||||
private final RectVar cache = Rect.makeVar();
|
|
||||||
private final Rect source;
|
|
||||||
private boolean inited = false;
|
|
||||||
|
|
||||||
|
|
||||||
public RectCache(Rect source) {
|
|
||||||
this.source = source;
|
|
||||||
enableDigestCaching(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Rect getSource()
|
|
||||||
{
|
|
||||||
if (!inited) poll();
|
|
||||||
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update cached value and cached digest (if digest caching is enabled)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void poll()
|
|
||||||
{
|
|
||||||
inited = true;
|
|
||||||
cache.setTo(source);
|
|
||||||
|
|
||||||
super.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package mightypork.utils.math.constraints.rect;
|
|||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.num.NumConst;
|
import mightypork.utils.math.constraints.num.NumConst;
|
||||||
|
import mightypork.utils.math.constraints.rect.caching.RectDigest;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectConst;
|
import mightypork.utils.math.constraints.vect.VectConst;
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1,7 +1,9 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.builders;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
import mightypork.utils.math.constraints.rect.proxy.RectProxy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +23,7 @@ public class TiledRect extends RectProxy {
|
|||||||
private int based = 1;
|
private int based = 1;
|
||||||
|
|
||||||
|
|
||||||
TiledRect(Rect source, int horizontal, int vertical) {
|
public TiledRect(Rect source, int horizontal, int vertical) {
|
||||||
super(source);
|
super(source);
|
||||||
this.tilesX = horizontal;
|
this.tilesX = horizontal;
|
||||||
this.tilesY = vertical;
|
this.tilesY = vertical;
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package mightypork.utils.math.constraints.rect.caching;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.ConstraintCache;
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
import mightypork.utils.math.constraints.rect.mutable.RectVar;
|
||||||
|
import mightypork.utils.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 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) markDigestDirty();
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void enableCaching(boolean yes)
|
||||||
|
{
|
||||||
|
cachingEnabled = yes;
|
||||||
|
enableDigestCaching(yes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isCachingEnabled()
|
||||||
|
{
|
||||||
|
return cachingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package mightypork.utils.math.constraints.rect.caching;
|
||||||
|
|
||||||
|
|
||||||
|
import mightypork.utils.annotations.DefaultImpl;
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rect cache implementation
|
||||||
|
*
|
||||||
|
* @author 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 onChange()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.caching;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
import mightypork.utils.math.constraints.rect.RectConst;
|
||||||
|
|
||||||
|
|
||||||
public class RectDigest {
|
public class RectDigest {
|
||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.mutable;
|
||||||
|
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.mutable;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectVar;
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
|
||||||
|
|
||||||
public class RectVar extends RectMutable {
|
public class RectVar extends RectMutable {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.proxy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-2
@@ -1,8 +1,9 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.proxy;
|
||||||
|
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
import mightypork.utils.math.constraints.vect.VectAdapter;
|
import mightypork.utils.math.constraints.vect.proxy.VectAdapter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
|
||||||
|
|
||||||
public class RectProxy extends RectAdapter {
|
public class RectProxy extends RectAdapter {
|
||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
package mightypork.utils.math.constraints.rect;
|
package mightypork.utils.math.constraints.rect.proxy;
|
||||||
|
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
import mightypork.utils.math.constraints.vect.Vect;
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ import mightypork.utils.math.constraints.vect.Vect;
|
|||||||
*
|
*
|
||||||
* @author MightyPork
|
* @author MightyPork
|
||||||
*/
|
*/
|
||||||
class RectVectAdapter extends Rect {
|
public class RectVectAdapter extends Rect {
|
||||||
|
|
||||||
private final Vect origin;
|
private final Vect origin;
|
||||||
private final Vect size;
|
private final Vect size;
|
||||||
@@ -3,10 +3,17 @@ package mightypork.utils.math.constraints.vect;
|
|||||||
|
|
||||||
import mightypork.utils.annotations.DefaultImpl;
|
import mightypork.utils.annotations.DefaultImpl;
|
||||||
import mightypork.utils.annotations.FactoryMethod;
|
import mightypork.utils.annotations.FactoryMethod;
|
||||||
|
import mightypork.utils.math.constraints.DigestCache;
|
||||||
import mightypork.utils.math.constraints.Digestable;
|
import mightypork.utils.math.constraints.Digestable;
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumConst;
|
import mightypork.utils.math.constraints.num.NumConst;
|
||||||
import mightypork.utils.math.constraints.rect.Rect;
|
import mightypork.utils.math.constraints.rect.Rect;
|
||||||
|
import mightypork.utils.math.constraints.vect.caching.VectCache;
|
||||||
|
import mightypork.utils.math.constraints.vect.caching.VectDigest;
|
||||||
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
import mightypork.utils.math.constraints.vect.proxy.VectBound;
|
||||||
|
import mightypork.utils.math.constraints.vect.proxy.VectBoundAdapter;
|
||||||
|
import mightypork.utils.math.constraints.vect.proxy.VectNumAdapter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,9 +111,15 @@ public abstract class Vect implements VectBound, Digestable<VectDigest> {
|
|||||||
private Num p_xc;
|
private Num p_xc;
|
||||||
private Num p_yc;
|
private Num p_yc;
|
||||||
private Num p_zc;
|
private Num p_zc;
|
||||||
private VectDigest lastDigest = null;
|
|
||||||
private boolean digestCachingEnabled = false;
|
private DigestCache<VectDigest> dc = new DigestCache<VectDigest>() {
|
||||||
private boolean digestDirty = true; // it's null
|
|
||||||
|
@Override
|
||||||
|
protected VectDigest createDigest()
|
||||||
|
{
|
||||||
|
return new VectDigest(Vect.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -254,38 +267,28 @@ public abstract class Vect implements VectBound, Digestable<VectDigest> {
|
|||||||
@Override
|
@Override
|
||||||
public VectDigest digest()
|
public VectDigest digest()
|
||||||
{
|
{
|
||||||
if (digestCachingEnabled) {
|
return dc.digest();
|
||||||
if (digestDirty) {
|
|
||||||
lastDigest = new VectDigest(this);
|
|
||||||
digestDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastDigest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new VectDigest(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableDigestCaching(boolean yes)
|
public void enableDigestCaching(boolean yes)
|
||||||
{
|
{
|
||||||
digestCachingEnabled = yes;
|
dc.enableDigestCaching(yes);
|
||||||
digestDirty = true; // schedule update nest time digest() is called
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDigestCachingEnabled()
|
public boolean isDigestCachingEnabled()
|
||||||
{
|
{
|
||||||
return digestCachingEnabled;
|
return dc.isDigestCachingEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void poll()
|
public void markDigestDirty()
|
||||||
{
|
{
|
||||||
if (digestCachingEnabled) digestDirty = true;
|
dc.markDigestDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* A vect cache.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* Values are held in a caching VectVar, and digest caching is enabled by
|
|
||||||
* default.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author MightyPork
|
|
||||||
*/
|
|
||||||
public class VectCache extends VectAdapter {
|
|
||||||
|
|
||||||
private final VectVar cache = Vect.makeVar();
|
|
||||||
private final Vect source;
|
|
||||||
private boolean inited = false;
|
|
||||||
|
|
||||||
|
|
||||||
public VectCache(Vect source) {
|
|
||||||
this.source = source;
|
|
||||||
enableDigestCaching(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Vect getSource()
|
|
||||||
{
|
|
||||||
if (!inited) poll();
|
|
||||||
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update cached value and cached digest (if digest caching is enabled)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void poll()
|
|
||||||
{
|
|
||||||
inited = true;
|
|
||||||
cache.setTo(source);
|
|
||||||
|
|
||||||
super.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ package mightypork.utils.math.constraints.vect;
|
|||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumConst;
|
import mightypork.utils.math.constraints.num.NumConst;
|
||||||
import mightypork.utils.math.constraints.rect.RectConst;
|
import mightypork.utils.math.constraints.rect.RectConst;
|
||||||
|
import mightypork.utils.math.constraints.vect.caching.VectDigest;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.vect.proxy.VectAdapter;
|
||||||
|
|
||||||
|
|
||||||
public class VectProxy extends VectAdapter {
|
public class VectProxy extends VectAdapter {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package mightypork.utils.math.constraints.vect.caching;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.ConstraintCache;
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
import mightypork.utils.math.constraints.vect.mutable.VectVar;
|
||||||
|
import mightypork.utils.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 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();
|
||||||
|
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void enableCaching(boolean yes)
|
||||||
|
{
|
||||||
|
cachingEnabled = yes;
|
||||||
|
enableDigestCaching(yes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isCachingEnabled()
|
||||||
|
{
|
||||||
|
return cachingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package mightypork.utils.math.constraints.vect.caching;
|
||||||
|
|
||||||
|
|
||||||
|
import mightypork.utils.annotations.DefaultImpl;
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vect cache implementation
|
||||||
|
*
|
||||||
|
* @author 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 onChange()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.caching;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
public class VectDigest {
|
public class VectDigest {
|
||||||
+3
-2
@@ -1,11 +1,12 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.mutable;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.gamecore.control.timing.Pauseable;
|
import mightypork.gamecore.control.timing.Pauseable;
|
||||||
import mightypork.gamecore.control.timing.Updateable;
|
import mightypork.gamecore.control.timing.Updateable;
|
||||||
import mightypork.utils.annotations.FactoryMethod;
|
import mightypork.utils.annotations.FactoryMethod;
|
||||||
import mightypork.utils.math.Easing;
|
import mightypork.utils.math.Easing;
|
||||||
import mightypork.utils.math.constraints.num.NumAnimated;
|
import mightypork.utils.math.constraints.num.mutable.NumAnimated;
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.mutable;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.mutable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +17,7 @@ public class VectVar extends VectMutable {
|
|||||||
* @param y Y coordinate
|
* @param y Y coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
*/
|
*/
|
||||||
VectVar(double x, double y, double z) {
|
public VectVar(double x, double y, double z) {
|
||||||
super();
|
super();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.proxy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.proxy;
|
||||||
|
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
public class VectBoundAdapter extends VectAdapter implements PluggableVectBound {
|
public class VectBoundAdapter extends VectAdapter implements PluggableVectBound {
|
||||||
+4
-3
@@ -1,8 +1,9 @@
|
|||||||
package mightypork.utils.math.constraints.vect;
|
package mightypork.utils.math.constraints.vect.proxy;
|
||||||
|
|
||||||
|
|
||||||
import mightypork.utils.math.constraints.num.Num;
|
import mightypork.utils.math.constraints.num.Num;
|
||||||
import mightypork.utils.math.constraints.num.NumBound;
|
import mightypork.utils.math.constraints.num.proxy.NumBound;
|
||||||
|
import mightypork.utils.math.constraints.vect.Vect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +11,7 @@ import mightypork.utils.math.constraints.num.NumBound;
|
|||||||
*
|
*
|
||||||
* @author MightyPork
|
* @author MightyPork
|
||||||
*/
|
*/
|
||||||
class VectNumAdapter extends Vect {
|
public class VectNumAdapter extends Vect {
|
||||||
|
|
||||||
private final Num constrX;
|
private final Num constrX;
|
||||||
private final Num constrY;
|
private final Num constrY;
|
||||||
Reference in New Issue
Block a user