Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageSpatial2D::In::wrap() #794

Merged
merged 7 commits into from
Aug 10, 2022
Merged

MessageSpatial2D::In::wrap() #794

merged 7 commits into from
Aug 10, 2022

Conversation

Robadob
Copy link
Member

@Robadob Robadob commented Feb 9, 2022

Python Circles 2D wrapped example here.

Currently operator++() only returns messages within the search radius, this is different to regular spatial messages.
I'm kind of torn on whether to keep this behaviour which adds a redundant extra load of each location variable and caches the distance, or to revert back to non-wrapped behaviour and provide a distance function which users must pass 2-4 floats to for the result.

Not to sure what else can be tested, just feels like it probably needs more.

Docs might need some minor redrafting, didn't feel too clean.

Haven't added an example to the main repo (there's already too much bloat with multiple versions of circles).

Docs PR: FLAMEGPU/FLAMEGPU2-docs#90

Closes #185

@Robadob Robadob marked this pull request as draft February 9, 2022 20:11
@ptheywood

This comment was marked as outdated.

@Robadob

This comment was marked as outdated.

@Robadob

This comment was marked as outdated.

@Robadob
Copy link
Member Author

Robadob commented May 27, 2022

Have just updated this to work with current master (post shared mem curve), also updated the gist example as it was using old dependency graph API.

@Robadob
Copy link
Member Author

Robadob commented Jun 15, 2022

Now working on this again, to summarise current status.

The wrapped iterator's Message object has these additional methods distinct from the normal iterator.

  • getDistance(): Returns the shortest distance to message in wrapped environment
  • getVirtualX(float x1): Returns the closest x coordinate in a wrapped environment (so if it wraps over the left edge, this will return a coordinate beyond the left edge)
  • getVirtualY(float y1)

This is different from the regular iterator, that the wrapped iterator only returns messages which are within the radius. This was setup that way when I initially developed the example (presumably in an attempt to minimise users doing stuff wrong), and could easily be tweaked to match the regular iterator's behaviour.

I now need to come up with some thorough tests for this and document, then repeat for 3D.

Needs better testing, will post model I was playing with in PR comments.
It might be a little naive, but should catch if things break badly.
+some additional minor cleanup (mostly removing redundant references.
@Robadob Robadob marked this pull request as ready for review June 15, 2022 14:16
@Robadob Robadob requested review from ptheywood and mondus June 15, 2022 14:16
@Robadob

This comment was marked as resolved.

Improve tests for non-zero environment min and out of bounds.
@ptheywood
Copy link
Member

We should think about how we can control wrapping in some but not all dimensions if required (i.e. wrapping in 3 dimensions creates a shape which can't be represented in 3D space, with FLAME GPU 1 only warpping in X and Y but never Z to form a torus)

Will try and get this reviewed in the net few days otherwise

@Robadob
Copy link
Member Author

Robadob commented Jun 27, 2022

As discussed in meeting, I've now removed the wrapped distance function entirely. It works more like regular spatial. With additional getVirtualX() and getVirtualX(float) methods for each axis, these provide the 'wrapped' coordinate relative to the search origin or a user specified coordinate respectively (the latter is probably not required, but probably harmless.

These methods internally call getVariable<float>("x"), it's intended that users call them, rather than loading the variables themselves.

P.S. Haven't addressed Pete's partial axis wrapping, don't believe Paul wanted it from the discussion (I might be wrong).

Copy link
Member

@mondus mondus left a comment

Choose a reason for hiding this comment

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

I am happy with the changes. Think the interface for this is really nice.

@mondus
Copy link
Member

mondus commented Jul 20, 2022

Delay merging to have a discussion about iterator for spatial messaging. There is a fairly good argument that this should do distance checking.

@mondus mondus merged commit e176d8a into master Aug 10, 2022
@mondus mondus deleted the experiment_spatial_wrap branch August 10, 2022 14:42
mondus pushed a commit that referenced this pull request Aug 11, 2022
* MessageSpatial2D::In::wrap()

Needs better testing, will post model I was playing with in PR comments.

* Add getVirtualX() getVirtualY() to the wrapped iterator message.

* Add a test that spatial2D wrapped messages work as intended.

It might be a little naive, but should catch if things break badly.

* 3D support and test added

+some additional minor cleanup (mostly removing redundant references.

* docs fix

* Add SEATBELTS to catch out of bounds messages.

Improve tests for non-zero environment min and out of bounds.

* Updates following FGPU meeting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrapped continuous spatial messaging
4 participants