Skip to content

Add support for 3D simulations#38

Merged
metaphori merged 93 commits intoscafi:developfrom
AleGnucci:master
Jan 29, 2020
Merged

Add support for 3D simulations#38
metaphori merged 93 commits intoscafi:developfrom
AleGnucci:master

Conversation

@AleGnucci
Copy link
Copy Markdown

This pull request adds to Scafi the support for 3D simulations.

metaphori and others added 30 commits January 15, 2020 10:29
…tegration with scafi, changing Point2D to Point3D where needed
…lator-gui and continued work on integration with renderer-3d
…s moving to the wrong position, also added Controller interface for easier integration with Scafi
…he correct colors are assigned when setting sensors.
…o that it's possible to right click. Also now the scene can be reset.
…when needed. Finally, the north menu shows correctly.
…dinate too. The 3d simulation should now also be faster but there is a problem with the javaFx UI thread getting flooded
…ails. Also worket more to use ScatterMesh to optimize the rendering.
…the selection volume can be done in laptops.
…xed a bug that sometimes prevented the camera from moving
…umption before executing the correct handler
Copy link
Copy Markdown
Contributor

@metaphori metaphori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

var position: Point2D
var position: Point3D

def position2d: Point2D
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having both fields seem redundant. We should consider dropping position2d and just keeping position. 2D simulations shouldn't be affected, using Point3D objects with z=0, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

position2d is implemented simply as position with z=0. I created it so that the code that expects a Point2D still works without making any changes to it. Should i modify each use of Node's position so that they always expect a Point3D?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may drop position2d and when a 2D position is needed, just provide the 2D-view of the 3D position (maybe an implicit converter can safely help).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove position2d. Would it be ok to put def toPoint2D: Point2D = new Point2D(p.x, p.y) inside it.unibo.scafi.space.optimization.RichPoint3D (or maybe even in Point3D itself)? That way everyone can reuse the 2d view logic.

Copy link
Copy Markdown
Contributor

@metaphori metaphori Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that

  • Point2D is a subclass of Point3D
  • Point3D already has an implicit def toPoint2D(p: Point3D): Point2D = Point2D(p.x, p.y)
    The latter can also be called explicitly, so there is no need of a new method.

Comment thread .travis.yml
env:
global:
- RELEASE_SCALA_VERSION=2.12.2
- RELEASE_SCALA_VERSION=2.12.10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for this increment of the version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done to avoid Scala-JDK compatibility problems when using JDK11.
I checked on docs.scala-lang.org and 2.12.4 seems the minimum 2.12 version required for JDK11, but it also says that

As of Scala 2.13.0, 2.12.8 and 2.11.12, JDK 11 support is incomplete

I finally saw that on the “Support JDK 11” issue they recently added

In general, Scala now works just fine on JDK 11

so i decided to upgrade to scala 2.12.10, to be safe.
Should i use a different version?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'd say it is fine! Thanks


override def _3: Double = z

override def canEqual(otherObject: Any): Boolean = otherObject match {case _: Point3D => true; case _ => false}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this caught by scala style?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scalastyle is not catching it for me. I can rewrite canEqual as otherObject.isInstanceOf[Point3D], would that be ok?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is fine.
I was now thinking if we wanted Point3D(1,1,0)==Point2D(1,1) to be true or not: it might be reasonable but if this wasn't so before, that's fine.

@AleGnucci
Copy link
Copy Markdown
Author

Some TravisCI builds failed to download a bunch of dependencies, but my last commit simply modified some scala files. I think that at that moment Maven wasn't responding, so maybe we just have to retry the builds. Do i do that creating an empty commit?

@metaphori metaphori merged commit 92813dd into scafi:develop Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants