deep copy / clone a object
- private PApplet p;
- private BezierMethods bezierMethods = BezierMethods.getInstance();
- // It's set to private so the user can't access the control points
- // private BezierVertex start;
- private ArrayList<BezierVertex> bezierVertexes = new ArrayList<BezierVertex>();
- protected float l; // length of the total path
- // when a bezierVertex get's added or a position get's changed it get's
- // dirty
- private boolean dirty = true;
- // extra one for the arc length parameterization
- private boolean dirtyALP = true;
- protected boolean dirtyWeight = true;
- // arc length parameterization on/off
- protected boolean alp = false;
- // stores length, points and tangents for faster return
- private boolean ALPStore = false;
- private ALP_info ALP_info;
- // stepAccuracy is used for bezierMethods
- private float stepAccuracy = 0.85f;
- private boolean lockControls = true;
- // stores at what value t is found (for closestBezierPoint for example)
- protected float targetT;
- // when true the end will be connected to the start
- private boolean close = false;
ALP_info is a inner class of BezierVertexPath that holds:
- float l;
- float[] bezierLengths;
- PVector[] bezierPoints;
- PVector[] bezierTangents;
And BezierVertex (holded in the ArrayList in the BezierVertexPath class) contains a few objects simulair PVector (but called CVector).
I want to be able to make a copy/clone of BezierVertexPath. However, all deeper fields/objects should be copied as well.
There are multiple ways to do and i have no experience with it.
What i dislike about a constructor like this:
- BezierVertexPath(BezierVertexPath original) {
- // code
- }
Is that i'm afraid to forget to add new fields that i might add in the future which might lead to hard to fix bugs.
I can't really figure out the difference between a deep copy and a clone, is it only the way how it get's created?
And what would be easier in my case judging from the fields given above?
Hope someone can help, internet is confusing the hell out of me :)