Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Add 3D view #6

Open
travellingkiwi opened this issue Aug 7, 2016 · 14 comments
Open

Add 3D view #6

travellingkiwi opened this issue Aug 7, 2016 · 14 comments

Comments

@travellingkiwi
Copy link

A 3D view would be nice...

@noberasco
Copy link
Contributor

Hi travellingkiwi,

you mentioned having a working demo implementation in Metal?
I would be interested in having a look at it :-)

@noberasco noberasco changed the title Add 3D view (Enhancement) Add 3D view Aug 10, 2016
@travellingkiwi
Copy link
Author

Sure… How would you like it? Fork a copy and push the commit? It’s a bit raw at the moment… But does show the stars and your path.

On 10 Aug 2016, at 22:57, noberasco [email protected] wrote:

Hi travellingkiwi,

you mentioned having a working demo implementation in Metal?
I would be interested in having a look at it :-)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #6 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ARG0q9oBzNL3EaNuzRCLZQPo8mNX_AQIks5qekk2gaJpZM4Jedk9.

@travellingkiwi
Copy link
Author

Hi.

Try [email protected]:travellingkiwi/EDDiscovery-Mac.git

regards
Hamish

On 10 Aug 2016, at 22:57, noberasco [email protected] wrote:

Hi travellingkiwi,

you mentioned having a working demo implementation in Metal?
I would be interested in having a look at it :-)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #6 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ARG0q9oBzNL3EaNuzRCLZQPo8mNX_AQIks5qekk2gaJpZM4Jedk9.

@noberasco
Copy link
Contributor

Hi Hamish,

I had a look at it and I must say it looks very promising!

I believe this is something that would make a really great addition to EDDiscovery. Are you interested in going on with its development? If so, I can give you commit rights to the base repo...

These are my suggestions for improving on what you already built:
1 - change the initial point of view so that it shows the galaxy from above (like the 2D map); initial zoom could be 'fit the whole galaxy in'
2 - don't auto-rotate the view
3 - tilt the galaxy plane by (left?)-dragging the mouse vertically
4 - rotate the galaxy plane by (left?)-dragging the mouse horizontally
5 - pan the view by (right?)-dragging the mouse (horizontally and vertically)
6 - zoom in / out using the mouse wheel (and the pinch gesture if it is implemented separately)

BTW, it seems to crash if you switch to a different view, then back to the 3D view.

I believe these changes could be enough for a first integration into EDDiscovery...

About showing station locations, that is also a nice idea, but since the paths are hardcoded to your own home directory I have no way to see it in action... but I think we can discuss this farther on ;-)

@travellingkiwi
Copy link
Author

  1. Yeah. Initial default. But I plan on saving the last location and starting from there. Probably need some controls down the side... Or keys to select different views (look @ current, look above etc)
  2. Yeah. That's just because I haven't done the controls yet. And a static picture just annoyed me
  3. yes - needs gestures to be implemented
  4. yes - needs gestures to be implemented
  5. yes - needs gestures to be implemented
  6. yes - needs gestures to be implemented

The crash has been fixed in the latest updates to the fork. Currently working on loading the data in the background. Sadly loading the galaxy list from core data seems to require the main thread. Which stops everything for several seconds.

@travellingkiwi
Copy link
Author

Are you interested in going on with its development? If so, I can give you commit rights to the base repo...

yes... I'm on a roll with this one.

On the station code... Only the background loading is implemented... It was actually just playing with getting the URL loading in the background. The database needs doing to save the info. And the code needs to be changed to pull the station data once a day from EDDB.

That needs to be generic, because I'd like to change the EDSM loading to background as well.

And the 3D view needs a way to have new data added to it...

And I'd prefer the display to show the jump list under the 3D view. So you can see both at once... And a one-two liner at the bottom to show what is happening (download EDSM/EDDB, uploading, idle etc)

Oh... And the graphics are a bit basic... It uses points, so when you zoom in the journey stars become square blocks... That needs to have a filled (Or textured) sphere. It would be nice to be able to zoom into a system and have it show an orrery view as well... Might need to start a list of 'issues' for improvements :)

The list goes on...

@noberasco
Copy link
Contributor

Hi @travellingkiwi, sorry for having been silent so long.

I had a long stream of issues in real life that needed my attention.

I see that you have not been sitting idle in the mean while :-)
I'm going to have another look at your changes...

@noberasco
Copy link
Contributor

Hi @travellingkiwi, I'm trying to give the latest version of your code a test run.

Unfortunately, it consistently crashes on me when attempting to load systems.
Easy fix, see below.

From what I could see, you are accessing MAIN_CONTEXT from a background thread, which is something you cannot do: all access to core data must be done via either performBlock or performBlockAndWait. This includes not only the fetching but also the handling of data (such as accessing their properties). The only exception is MAIN_CONTEXT, which can be accessed directly, but only from the main thread.

After wrapping all of the logic contained within loadJumpsAndWaypoints in a performBlockAndWait on WORK_CONTEXT, it all started working.

The rendering is impressive!

I see that you took into account some of my remarks for navigating the view :-)

Leftover issues, in order of priority:
1 - it still crashes when changing to another view, then back to the 3D view
2 - it should not consume CPU when not visible (e.g. a different tab is selected)
3 - it still misses the ability to move around the view, as it always stays centered on the same spot
4 - it is pretty hard to see my own travel line within the mass of stars
5 - cpu usage is really high when the 3D view is visible, even if I'm not moving around

I think that fixing points 1 and 2 above would be enough to publish a first official version of EDDiscovery with your code added in!

@noberasco
Copy link
Contributor

Attached you will find the changes I had to make to loadJumpsAndWaypoints in order to prevent it from crashing.

loadJumpsAndWaypoints.txt

@noberasco
Copy link
Contributor

Note that if you use performBlock instead of performBlockAndWait it will run asynchronously without blocking the main thread, but then apparently the 3D view won't display all systems...

@noberasco
Copy link
Contributor

Correction: it will display them all, but they will be added in progressive batches, with each subsequent batch taking progressively longer to display.

@noberasco
Copy link
Contributor

I also tried not displaying all the stars in the 3D view. Loading times and performance are vastly improved this way, with no noticeable CPU usage. Also, it does not crash when returning to the 3D view.

I'm tempted to include this variant for a first integration...

@travellingkiwi
Copy link
Author

Yeah. There's a bunch of updates I have in mind... I should raise issues for them all to track.

Does the status UITextView scroll for you? It's stopped scrolling on my current version (Not committed yet). Having trouble finding why... It SHOULD scroll to the end. But doesn't.

@travellingkiwi
Copy link
Author

From above

1 - it still crashes when changing to another view, then back to the 3D view

It shouldn't I fixed that a while ago... Maybe I didn't push that change. I will check when Xcode back up (I started to update to 8 but am in a hotel in Malta so download a bit slow).

2 - it should not consume CPU when not visible (e.g. a different tab is selected)

Agreed... That one needs looking at as it SHOULD pause while not visible, but I think the code that I reused from the sample is really meant for non-tabbed displays... So we miss the notification that we're going away and coming back

3 - it still misses the ability to move around the view, as it always stays centered on the same spot

True

4 - it is pretty hard to see my own travel line within the mass of stars

Even with default? Maybe I really didn't push... I've been trying to track down why the scrolling on the status went away for a while... Which happened around the same time that I changed a lot of the metal code to implement a bit of transparency to the points that represent the stars and amended the colours. Also implemented a fading of the intensity with distance. And split the drawing into separate metal fragment shaders.

5 - cpu usage is really high when the 3D view is visible, even if I'm not moving around

Yeah... Two things here
a. I need to NOT re-draw if nothing has changed (Should be a simple fix)
b. HW acceleration really changes this. On my MBPro I get about 25-30% CPU (core) usage and 50% GPU. On my MacPro 2013 I get 110% CPU (core) usage and 0% GPU... That worries me. Although my M'Pro is still on el-Capitan (Laptop is Sierra now, but no change on laptop from el-cap to sierra that has been noticed - hoping sierra update on M'Pro will 'fix' the lack of acceleration).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants