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

Virtual Floor #6338

Merged
merged 30 commits into from
Jan 11, 2018
Merged

Conversation

JeroenDStout
Copy link
Contributor

Add a virtual floor to the game, activated by the alt/shift method of placing things at different heights.

surface0

It displays a grid on which obstructing elements and walls are highlighted as bright edges.

surface1

While constructing a ride pressing shift places the virtual floor on a corresponding level, making it possible to see the possible scenery collisions.

surface2

It also works underground.

underground

This is WIP:

  • Currently only works in OpenGL renderer (redraw regions still need to be added)
  • It is not yet fully updated for constructing paths
  • It should probably have a toggle in view options
  • I believe it could be tweaked to be better, based on feedback. There potentially are also some bugs which my own play-style has hidden from me.

But:

  • Some sprites will never proper sort with the grid unless the sorting is fixed.

@JeroenDStout
Copy link
Contributor Author

Could someone help me understand the Travis errors?

I am not sure what ninja: build stopped: cannot make progress due to previous errors (no further information) means. The other error is just ld: symbol(s) not found for architecture x86_64, which I also do not understand.

@janisozaur
Copy link
Member

@JeroenDStout like ninja ssays, the error is a bit earlier. See https://travis-ci.org/OpenRCT2/OpenRCT2/jobs/281783225#L589:

map_element.c:(.text+0x77e): undefined reference to `virtual_floor_paint'

Most likely difference in bindings (C vs C++) in some place.

And don't worry about Xcode, it's special snowflake and needs to be dealt with appropriately.


void map_invalidate_virtual_floor_tiles()
{
}
Copy link
Member

Choose a reason for hiding this comment

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

missing newline

sub_98197C(session, SPR_G2_SELECTION_EDGE_SE | (!(occupiedEdges & 0x2)? ((litEdges & 0x2)? remap_lit : remap_base) : remap_edge),
0, 0, 1, 1, 1, gMapVirtualFloorHeight, 16, 27, gMapVirtualFloorHeight + ((dullEdges & 0x2)? -2 : 0), get_current_rotation());
}
}
Copy link
Member

Choose a reason for hiding this comment

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

missing newline

@janisozaur
Copy link
Member

Ride supports don't cause the edges to become white. They look very solid to me and I expected them to be identified as collision too.

@janisozaur
Copy link
Member

The new sprites are not optimised.

@Krutonium
Copy link
Member

@janisozaur Ride Supports don't cause collisions - they move out of the way or are removed entirely depending on what is under them. I support them not being marked as collision, since they aren't.

@JeroenDStout
Copy link
Contributor Author

@janisozaur @PFCKrutonium The purpose is primarily a collision test, in the end. Supports could be added but would give you a false impression of the region; unless they were a different colour, but then the amount of information may just become too large.

@JeroenDStout
Copy link
Contributor Author

@janisozaur Could you help out with the virtual_floor_paint problem? As far as I can tell, map_element.c includes map_element.h, which contains a declaration of virtual_floor_paint. I think there is a C idiosyncrasy that I am missing.

@Gymnasiast Gymnasiast changed the title (WIP) Virtual Floor Virtual Floor Oct 2, 2017

void virtual_floor_paint(paint_session * session)
{
// We only show when the placement modifier keys are active
Copy link
Member

Choose a reason for hiding this comment

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

Comments seem misaligned in this file

session->MapPosition.x <= tile->x + gMapVirtualFloorBaseSize &&
session->MapPosition.y <= tile->y + gMapVirtualFloorBaseSize)
{
show = true;
Copy link
Member

Choose a reason for hiding this comment

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

you can add break; here

show = true;
}
}
if (!show)
Copy link
Member

Choose a reason for hiding this comment

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

you can merge these two tail conditions into one after the if block starting in line 63

session->MapPosition.x == tile->x &&
session->MapPosition.y == tile->y)
{
weAreLit = true;
Copy link
Member

Choose a reason for hiding this comment

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

break

// Check if we are anywhere near the selection tiles (larger scenery / rides)
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)
{
for (tile = gMapSelectionTiles; tile->x != -1; tile++)
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer if you sank the variable declarations to where they are used, declare rct_xy16 * tile in each of the loops that use it

elementType == MAP_ELEMENT_TYPE_BANNER)
{
sint32 direction = map_element_get_direction(mapElement);
occupiedEdges |= 1 << ((direction + get_current_rotation()) % 4);
Copy link
Member

Choose a reason for hiding this comment

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

cache the rotation, it won't change mid-function

if (theirLocationX == tile->x &&
theirLocationY == tile->y)
{
theyAreLit = true;
Copy link
Member

Choose a reason for hiding this comment

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

break


mapElement = map_get_first_element_at(theirLocationX >> 5, theirLocationY >> 5);
do
{
Copy link
Member

Choose a reason for hiding this comment

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

This whole loop and the condition above looks pretty much the same as the we variant of it. Any chance you could refactor them into their own function and just call it for different tiles?

sub_98197C(session, SPR_G2_SELECTION_EDGE_NE | (!(occupiedEdges & 0x1)? ((litEdges & 0x1)? remap_lit : remap_base) : remap_edge),
0, 0, 0, 0, 1, gMapVirtualFloorHeight, 5, 5, gMapVirtualFloorHeight + ((dullEdges & 0x1)? -2 : 0), get_current_rotation());
}
if (paintEdges & 0x2)
Copy link
Member

Choose a reason for hiding this comment

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

0x2 seems out of order, does it also work if you move it above 0x1?

}

void map_invalidate_virtual_floor_tiles()
{
Copy link
Member

Choose a reason for hiding this comment

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

empty? a placeholder for software renderer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed - I'll make it with a TODO comment, next time

@JeroenDStout
Copy link
Contributor Author

I want to add a function call which removes (invalidates) the virtual floor when the modifiers are no longer used. In which function should I put this?

@Gymnasiast
Copy link
Member

@JeroenDStout Sounds like viewport.c to me, but I'd like to have that confirmed by @janisozaur .

@JeroenDStout
Copy link
Contributor Author

Lots of improvements, and it now is a bit more sane about checking whether the virtual floor needs to be drawn. Things still to do:

  • Allow building paths to set the virtual floor height
  • Add proper invalidation code to changes to the virtual floor (for software rendering)

JeroenDStout and others added 21 commits January 11, 2018 10:19
Cache the position of the last invalidate call to prevent a big dip in performance.
This addresses compilation issues for projects that contain no UI code.
Also working towards better invalidation for the software renderer.
Add a proper header file for the virtual floor in the process.
@AaronVanGeffen AaronVanGeffen removed the testing required PR needs to be tested before it is merged. label Jan 11, 2018
@AaronVanGeffen AaronVanGeffen merged commit 1d7bec8 into OpenRCT2:develop Jan 11, 2018
janisozaur added a commit that referenced this pull request Mar 18, 2018
- Feature: [#2893] Object selection filters for items from RCT1, Added Attractions and Loopy Landscapes.
- Feature: [#3505] Allow up to 1024 items per scenery tab.
- Feature: [#3510] Auto-append extension if none is specified.
- Feature: [#3994] Show bottom toolbar with map tooltip (theme option).
- Feature: [#4184] Add command and cheat to alter the date.
- Feature: [#4906] Add follow sprite command to title sequences.
- Feature: [#4984] Add option to highlight path issues: full bins, vandalism & vomit.
- Feature: [#5826] Add the show_limits command to show map data counts and limits.
- Feature: [#6078] Game now converts mp.dat to SC21.SC4 (Mega Park) automatically.
- Feature: [#6125] Path can now be placed in park entrances.
- Feature: [#6181] Map generator now allows adjusting random terrain and tree placement in Simplex Noise tab.
- Feature: [#6235] Add drawing debug option for showing visuals when and where blocks of the screen are painted.
- Feature: [#6290] Arabic translation (experimental).
- Feature: [#6292] Allow building queue lines in the Scenario Editor.
- Feature: [#6295] TrueType fonts are now rendered with light font hinting by default.
- Feature: [#6307] Arrows are now shown when placing park entrances.
- Feature: [#6313] Add keyboard shortcut for toggle gridlines.
- Feature: [#6324] Add command to deselect unused objects from the object selection.
- Feature: [#6325] Allow using g1.dat from RCT Classic.
- Feature: [#6329] Render level crossings when the Miniature Railway crossed a path.
- Feature: [#6338] Virtual floor to help positioning objects vertically.
- Feature: [#6353] Show custom RCT1 scenarios in New Scenario window.
- Feature: [#6411] Add command to remove the park fence.
- Feature: [#6414] Raise maximum launch speed of the Corkscrew RC back to 96 km/h (for RCT1 parity).
- Feature: [#6433] Turn 'unlock all prices' into a regular (non-cheat, persistent) option.
- Feature: [#6516] Ability to search by filename in the object selection window.
- Feature: [#6530] Land rights tool no longer blocks when a tile is not for purchase.
- Feature: [#6568] Add smooth nearest neighbour scaling.
- Feature: [#6651, #6658] Integrate Discord Rich Presence.
- Feature: [#6709] The New Ride window now shows available vehicles for a ride type.
- Feature: [#6731] Object indexing progress is now reported via command line output.
- Feature: [#6779] On-ride photo segment for Splash Boats.
- Feature: [#6838] Ability to auto-pause server when no clients are connected.
- Feature: [#7031] Better support for displaced ride entrances and exits.
- Feature: Add search box to track design window.
- Feature: Allow using object files from RCT Classic.
- Feature: Title sequences now testable in-game.
- Feature: Vehicles with matching capabilities are now always switchable.
- Feature: Add search box to track design window.
- Feature: Add load scenario command to title sequences.
- Fix: [#816] In the map window, there are more peeps flickering than there are selected (original bug).
- Fix: [#996, #2589, #2875] Viewport scrolling no longer shakes or gets stuck.
- Fix: [#1185] Close button colour of prompt windows does not match.
- Fix: [#1833, #4937, #6138] 'Too low!' warning when building rides and shops on the lowest land level (original bug).
- Fix: [#2254] Edge scrolling horizontally now has the same speed as vertical edge scrolling.
- Fix: [#2607] Rain rendered incorrectly in additional viewport.
- Fix: [#3171] Guests entering from the corner of the tile in Amity Airfield (original bug).
- Fix: [#3330] Current number of passengers overflows when over 255 (original bug).
- Fix: [#4760] Asia - Great Wall of China and South America - Rio Carnival have incorrect guest entry points (original bug).
- Fix: [#4953, #6277] Unable to advertise to master servers over IPv6.
- Fix: [#4991] Inverted helices can be built on the Lay Down RC, but are not drawn.
- Fix: [#5190] Cannot build Wild Mouse - Flying Dutchman Gold Mine.
- Fix: [#5224] Multiplayer window is not closed when server shuts down.
- Fix: [#5228] Top toolbar disappears when opening SC4 file.
- Fix: [#5261] Deleting a banner sign after copy/pasting it will crash the game.
- Fix: [#5398] Attempting to place Mini Maze.TD4 results in weird behaviour and crashes.
- Fix: [#5417] Hacked Crooked House tracked rides do not dispatch vehicles.
- Fix: [#5445] Patrol area not imported from RCT1 saves and scenarios.
- Fix: [#5585] Inconsistent zooming with mouse wheel.
- Fix: [#5609] Vehicle switching may cause '0 cars per train' to be set.
- Fix: [#5636] Pausing the game shows mute button as active.
- Fix: [#5741] Land rights indicators disappear when switching views.
- Fix: [#5761] Mini coaster doesn't appear despite being selected.
- Fix: [#5788] Empty scenario names cause invisible entries in scenario list.
- Fix: [#5809] Support Steam RCT1 file layout when loading CSG images.
- Fix: [#5838] Crash when saving very large track designs.
- Fix: [#5901] Placing peep spawn not synced across multiplayer.
- Fix: [#6101] Rides remain in ride list window briefly after demolition.
- Fix: [#6114] Crash when using a non-LL CSG1.DAT.
- Fix: [#6115] Random title screen music not random on launch.
- Fix: [#6118, #6245, #6366] Tracked animated vehicles not animating.
- Fix: [#6129] Guest List summary not updating after a ride rename.
- Fix: [#6133] Construction rights not shown after selecting buy mode.
- Fix: [#6188] Viewports not being clipped properly when zoomed out in OpenGL mode.
- Fix: [#6193] All rings in Space Rings use the same secondary colour.
- Fix: [#6196, #6223] Guest's energy underflows and never decreases.
- Fix: [#6198] You cannot cancel RCT1 directory selection.
- Fix: [#6199] Inverted Hairpin Coaster vehicle tab is not centred.
- Fix: [#6202] Guests can break occupied benches (original bug).
- Fix: [#6251] Splash Boats renders flat-to-25-degree pieces in tunnels incorrectly.
- Fix: [#6261, #6344, #6520] Broken pathfinding after removing park entrances with the tile inspector.
- Fix: [#6271] Wrong booster speed tooltip text.
- Fix: [#6293] Restored interface sounds while gameplay is paused.
- Fix: [#6301] Track list freezes after deleting track in Track Manager.
- Fix: [#6308] Cannot create title sequence if title sequences folder does not exist.
- Fix: [#6314] Imported SV4 files do not mark their scenarios as completed.
- Fix: [#6318] Cannot sack staff that have not been placed.
- Fix: [#6320] Crash when CSS1.DAT is absent.
- Fix: [#6331] Scenery costs nothing in track designs.
- Fix: [#6358] HTTP requests can point to invalid URL string.
- Fix: [#6360] Off-by-one filenames when exporting all sprites.
- Fix: [#6388] Construction rights tool erroneously enabled in some RCT1 scenarios even when no rights are available.
- Fix: [#6413] Maze previews only showing scenery.
- Fix: [#6423] Importing parks containing names with Polish characters.
- Fix: [#6423] Polish characters now correctly drawn when using the sprite font.
- Fix: [#6445] Guests' favourite ride improperly set when importing from RCT1 or AA.
- Fix: [#6452] Scenario text cut off when switching between 32 and 64-bit builds.
- Fix: [#6460] Crash when reading corrupt object files.
- Fix: [#6481] Can't take screenshots of parks with colons in the name.
- Fix: [#6500] Failure to load resources when config file is missing.
- Fix: [#6547] The server log is not logged if the server name contains CJK.
- Fix: [#6593] Cannot hire entertainers when default scenery groups are not selected (original bug).
- Fix: [#6657] Guest list is missing tracking icon after reopening.
- Fix: [#6803] Symbolic links to directories are not descended by FileScanner.
- Fix: [#6830] Crash when using mountain tool due to ride with no ride entry.
- Fix: [#6833] Shops in corrupted files not imported correctly.
- Fix: [#6846] Zoom level in some ride overview windows was erroneously set too high.
- Fix: [#6904] Manually added multiplayer servers not saved.
- Fix: [#7003] Building sloped paths through flat paths with clearance checks off causes glitches.
- Fix: [#7011] Swinging and bobsleigh cars going backwards swing in the wrong direction (original bug).
- Fix: [#7042, #7077] Paths sometimes disconnect when building them with clearance checks off.
- Fix: [#7125] No entry signs not correctly handled in pathfinding.
- Fix: [#7223] Vehicle mass not correctly recalculated when using remove all guests cheat.
- Fix: [#7229] Exploding guests cheat causes rides to get stuck and freezes game.
- Fix: [#7295] peep_should_go_on_ride_again() checked balloon colour instead of toilet need.
- Fix: [#7301] Sprite compiler dithering checks transparency of wrong pixel.
- Fix: Infinite loop when removing scenery elements with >127 base height.
- Fix: Ghosting of transparent map elements when the viewport is moved in OpenGL mode.
- Fix: Clear IME buffer after committing composed text.
- Fix: RCT1 mazes with wooden fences not imported correctly.
- Fix: Title sequence editor now gracefully fails to preview a title sequence and lets the user know with an error message.
- Fix: When preset title sequence fails to load, the preset will forcibly be changed to the first sequence to successfully load.
- Fix: Remove consecutive thoughts about a ride being demolished.
- Fix: Water raft vehicles stop spinning when going up slopes.
- Fix: Incorrect spin is applied to coasters on S-bends and other turns.
- Improved: [#5962] Use AVX2 instruction set where supported, resulting in a performance boost.
- Improved: [#5964] Use SSE 4.1 instruction set where supported, resulting in a performance boost.
- Improved: [#6186] Transparent menu items now draw properly in OpenGL mode.
- Improved: [#6218] Speed up game start up time by saving scenario index to file.
- Improved: [#6242] Prevent scenery aging and grass growth causing tile invalidation unless necessary - slight performance boost.
- Improved: [#6423] Polish is now rendered using the sprite font, rather than TTF.
- Improved: [#6746] Draw friction wheels instead of chain lift on Looping Roller Coaster stations.
- Improved: Load/save window now refreshes list if native file dialog is closed/cancelled.
- Improved: Major translation updates for Japanese and Polish.
- Improved: Added 24x24, 48x48, and 96x96 icon resolutions.
- Technical: [#6384] On macOS, address NSFileHandlingPanel deprecation by using NSModalResponse instead.
- Technical: [#6772] RCT2 interop removed.
Broxzier pushed a commit that referenced this pull request May 30, 2018
The virtual floor by @JeroenDStout, introduced in the v0.1.2 release, has generally been well-received. However, some players find it too intrusive in its current appearance (cf. #7221). This PR gives them the option of a toned-down version, rather than having to turn it off completely.

![screenshot_20180528_221350](https://user-images.githubusercontent.com/604665/40628292-6e71358e-62c4-11e8-9293-e166e75d0da6.png)

The clear/transparent style, introduced by this PR, looks like the virtual floor as originally introduced in #6338:
![](https://user-images.githubusercontent.com/14242454/31050274-e3f0e62e-a645-11e7-9b10-ec26b733d631.gif)

The glassy/translucent style is the virtual floor as we've come to know it since the v0.1.2 release, and remains the default setting.
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.

None yet

7 participants