1

There is no way to change the x,y,z values of a Point3D, even adding another point to an existing point creates a NEW point. (rather than adding the x,y,z values to the x,y,z fields of the existing point)

https://docs.oracle.com/javase/8/javafx/api/javafx/geometry/Point3D.html

This was obviously done for a reason, but it just seem like it would flood the GC with lots of needless Point3D object.

What am I missing ?

Chris Camacho
  • 1,164
  • 1
  • 9
  • 31
  • I don't know for this specific case but you can read about immutable objects e.g. at [Wikipedia](http://en.wikipedia.org/wiki/Immutable_object) or [at this question](http://stackoverflow.com/questions/214714/mutable-vs-immutable-objects). – Hauke Ingmar Schmidt Mar 30 '15 at 14:18
  • 1
    The JVM is designed to be extremely efficient at creating very short-lived, small immutable objects like this. As others have pointed out, immutable objects have lots of advantages over mutable objects, such as thread-safety. It's generally a good design to make simple, data-type objects such as this immutable. – James_D Mar 30 '15 at 14:34
  • 2
    Something which may have a lot of 3D points (e.g. millions), is a [TriangleMesh](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/shape/TriangleMesh.html) - note that its implementation does not use `Point3D` objects, it returns points in a (mutable) [ObservableFloatArray](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/shape/TriangleMesh.html#getPoints--), so there are mechanisms to modify large amounts of points without creating new objects. – jewelsea Mar 30 '15 at 17:34
  • You could ask the JavaFX developers this question directly on the [openjfx-dev mailing list](http://mail.openjdk.java.net/mailman/listinfo/openjfx-dev). – jewelsea Mar 30 '15 at 17:37

0 Answers0