Improvement: Added lighting effects for shops and stalls. (#14169)

* Improvement: Added lighting effects for shops and stalls.

* Moved offset rotations for lights to declaration.

* - Made function variables Const&, Const

- Fixed casing

- Removed direction variable from kiosk function

- Moved kiosk light offset rotation to declaration

* Ensure defines are only set for given target with cmake

Co-authored-by: Michał Janiszewski <janisozaur@gmail.com>
This commit is contained in:
WantDiscussion 2021-06-30 16:55:02 +10:00 committed by GitHub
parent 617bb698ae
commit 06026ec55e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 20 deletions

View File

@ -180,26 +180,6 @@ execute_process(
)
# Defines
if (USE_MMAP)
add_definitions(-DUSE_MMAP)
endif ()
if (DISABLE_NETWORK)
add_definitions(-DDISABLE_NETWORK)
endif ()
if (DISABLE_HTTP)
add_definitions(-DDISABLE_HTTP)
endif ()
if (DISABLE_TTF)
add_definitions(-DNO_TTF)
endif ()
if (ENABLE_LIGHTFX)
add_definitions(-D__ENABLE_LIGHTFX__)
endif ()
if (ENABLE_SCRIPTING)
add_definitions(-DENABLE_SCRIPTING)
endif ()
if (NOT DISABLE_DISCORD_RPC)
if (UNIX AND NOT APPLE)
find_package(DiscordRPC)
@ -366,6 +346,27 @@ if(NOT DISABLE_GUI)
include("${ROOT_DIR}/src/openrct2-ui/CMakeLists.txt" NO_POLICY_SCOPE)
endif()
# Defines
if (USE_MMAP)
target_compile_options(libopenrct2 PUBLIC -DUSE_MMAP)
endif ()
if (DISABLE_NETWORK)
target_compile_options(libopenrct2 PUBLIC -DDISABLE_NETWORK)
endif ()
if (DISABLE_HTTP)
target_compile_options(libopenrct2 PUBLIC -DDISABLE_HTTP)
endif ()
if (DISABLE_TTF)
target_compile_options(libopenrct2 PUBLIC -DNO_TTF)
endif ()
if (ENABLE_LIGHTFX)
target_compile_options(libopenrct2 PUBLIC -D__ENABLE_LIGHTFX__)
endif ()
if (ENABLE_SCRIPTING)
target_compile_options(libopenrct2 PUBLIC -DENABLE_SCRIPTING)
endif ()
# g2
add_custom_command(
OUTPUT g2.dat

View File

@ -803,6 +803,53 @@ void lightfx_add_lights_magic_vehicle(const Vehicle* vehicle)
};
}
void LightFxAddKioskLights(const CoordsXY& mapPosition, const int32_t height, const uint8_t zOffset)
{
uint8_t relativeRotation = (4 - get_current_rotation()) % 4;
CoordsXY lanternOffset1 = CoordsXY(0, 16).Rotate(relativeRotation);
CoordsXY lanternOffset2 = CoordsXY(16, 0).Rotate(relativeRotation);
lightfx_add_3d_light_magic_from_drawing_tile(
mapPosition, lanternOffset1.x, lanternOffset1.y, height + zOffset, LightType::Lantern3);
lightfx_add_3d_light_magic_from_drawing_tile(
mapPosition, lanternOffset2.x, lanternOffset2.y, height + zOffset, LightType::Lantern3);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, 8, 32, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, 32, 8, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, -32, 8, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, 8, -32, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, -8, 32, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, 32, -8, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, -32, -8, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, -8, -32, height, LightType::Spot1);
}
void LightFxAddShopLights(const CoordsXY& mapPosition, const uint8_t direction, const int32_t height, const uint8_t zOffset)
{
if (direction == (4 - get_current_rotation()) % 4) // Back Right Facing Stall
{
CoordsXY spotOffset1 = CoordsXY(-32, 8).Rotate(direction);
CoordsXY spotOffset2 = CoordsXY(-32, 4).Rotate(direction);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, spotOffset1.x, spotOffset1.y, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, spotOffset2.x, spotOffset2.y, height, LightType::Spot2);
}
else if (direction == (7 - get_current_rotation()) % 4) // Back left Facing Stall
{
CoordsXY spotOffset1 = CoordsXY(-32, -8).Rotate(direction);
CoordsXY spotOffset2 = CoordsXY(-32, -4).Rotate(direction);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, spotOffset1.x, spotOffset1.y, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, spotOffset2.x, spotOffset2.y, height, LightType::Spot2);
}
else // Forward Facing Stall
{
CoordsXY spotOffset1 = CoordsXY(-32, 8).Rotate(direction);
CoordsXY spotOffset2 = CoordsXY(-32, -8).Rotate(direction);
CoordsXY lanternOffset = CoordsXY(-16, 0).Rotate(direction);
lightfx_add_3d_light_magic_from_drawing_tile(
mapPosition, lanternOffset.x, lanternOffset.y, height + zOffset, LightType::Lantern3);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, spotOffset1.x, spotOffset1.y, height, LightType::Spot1);
lightfx_add_3d_light_magic_from_drawing_tile(mapPosition, spotOffset2.x, spotOffset2.y, height, LightType::Spot1);
}
}
void lightfx_apply_palette_filter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b)
{
float night = static_cast<float>(pow(gDayNightCycle, 1.5));

View File

@ -68,6 +68,9 @@ void lightfx_add_3d_light_magic_from_drawing_tile(
void lightfx_add_lights_magic_vehicle(const Vehicle* vehicle);
void LightFxAddKioskLights(const CoordsXY& mapPosition, const int32_t height, const uint8_t zOffset);
void LightFxAddShopLights(const CoordsXY& mapPosition, const uint8_t direction, const int32_t height, const uint8_t zOffset);
uint32_t lightfx_get_light_polution();
void lightfx_apply_palette_filter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b);

View File

@ -11,6 +11,7 @@
#include "../config/Config.h"
#include "../drawing/Drawing.h"
#include "../drawing/LightFX.h"
#include "../interface/Viewport.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
@ -2195,6 +2196,20 @@ void track_paint(paint_session* session, Direction direction, int32_t height, co
}
}
#ifdef __ENABLE_LIGHTFX__
if (lightfx_is_available())
{
uint8_t zOffset = 16;
if (ride->type == RIDE_TYPE_TOILETS || ride->type == RIDE_TYPE_FIRST_AID || ride->type == RIDE_TYPE_CASH_MACHINE)
zOffset = 23;
if (ride->type == RIDE_TYPE_INFORMATION_KIOSK)
LightFxAddKioskLights(session->MapPosition, height, zOffset);
else if (RideTypeDescriptors[ride->type].HasFlag(RIDE_TYPE_FLAG_IS_SHOP))
LightFxAddShopLights(session->MapPosition, tileElement->GetDirection(), height, zOffset);
}
#endif
session->InteractionType = ViewportInteractionItem::Ride;
session->TrackColours[SCHEME_TRACK] = SPRITE_ID_PALETTE_COLOUR_2(
ride->track_colour[trackColourScheme].main, ride->track_colour[trackColourScheme].additional);