mirror of https://github.com/OpenRCT2/OpenRCT2.git
Split paint item into element and entity
This commit is contained in:
parent
79989a5e84
commit
8aafab2a70
|
@ -65,6 +65,7 @@ static uint32_t _currentImageType;
|
|||
InteractionInfo::InteractionInfo(const paint_struct* ps)
|
||||
: Loc(ps->map_x, ps->map_y)
|
||||
, Element(ps->tileElement)
|
||||
, Entity(ps->entity)
|
||||
, SpriteType(ps->sprite_type)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -84,11 +84,8 @@ struct InteractionInfo
|
|||
InteractionInfo() = default;
|
||||
InteractionInfo(const paint_struct* ps);
|
||||
CoordsXY Loc;
|
||||
union
|
||||
{
|
||||
TileElement* Element = nullptr;
|
||||
EntityBase* Entity;
|
||||
};
|
||||
TileElement* Element{};
|
||||
EntityBase* Entity{};
|
||||
ViewportInteractionItem SpriteType = ViewportInteractionItem::None;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ void EntityPaintSetup(paint_session& session, const CoordsXY& pos)
|
|||
|
||||
const bool highlightPathIssues = (session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES);
|
||||
|
||||
for (const auto* spr : EntityTileList(pos))
|
||||
for (auto* spr : EntityTileList(pos))
|
||||
{
|
||||
if (highlightPathIssues)
|
||||
{
|
||||
|
@ -73,17 +73,6 @@ void EntityPaintSetup(paint_session& session, const CoordsXY& pos)
|
|||
}
|
||||
}
|
||||
|
||||
if ((session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_VEHICLES) && spr->Type == EntityType::Vehicle)
|
||||
{
|
||||
const auto veh = spr->As<Vehicle>();
|
||||
if (veh != nullptr)
|
||||
{
|
||||
auto ride = get_ride(veh->ride);
|
||||
if (ride != nullptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const auto entityPos = spr->GetLocation();
|
||||
|
||||
// Only paint sprites that are below the clip height and inside the clip selection.
|
||||
|
@ -119,7 +108,7 @@ void EntityPaintSetup(paint_session& session, const CoordsXY& pos)
|
|||
image_direction += spr->sprite_direction;
|
||||
image_direction &= 0x1F;
|
||||
|
||||
session.CurrentlyDrawnItem = spr;
|
||||
session.CurrentlyDrawnEntity = spr;
|
||||
session.SpritePosition.x = entityPos.x;
|
||||
session.SpritePosition.y = entityPos.y;
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
|
|
|
@ -57,7 +57,8 @@ static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t v
|
|||
static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y);
|
||||
static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y);
|
||||
static ImageId PaintPSColourifyImage(
|
||||
ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags);
|
||||
ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags, const TileElement* tileElement,
|
||||
const EntityBase* entity);
|
||||
|
||||
static int32_t RemapPositionToQuadrant(const paint_struct& ps, uint8_t rotation)
|
||||
{
|
||||
|
@ -193,7 +194,8 @@ static paint_struct* CreateNormalPaintStruct(
|
|||
ps->sprite_type = session.InteractionType;
|
||||
ps->map_x = session.MapPosition.x;
|
||||
ps->map_y = session.MapPosition.y;
|
||||
ps->tileElement = reinterpret_cast<TileElement*>(const_cast<void*>(session.CurrentlyDrawnItem));
|
||||
ps->tileElement = session.CurrentlyDrawnTileElement;
|
||||
ps->entity = session.CurrentlyDrawnEntity;
|
||||
|
||||
return ps;
|
||||
}
|
||||
|
@ -483,17 +485,6 @@ void PaintSessionArrange(PaintSessionCore& session)
|
|||
Guard::Assert(false);
|
||||
}
|
||||
|
||||
static EntityType GetEntityTypeFromPaintSession(const paint_struct* ps)
|
||||
{
|
||||
auto entityType = EntityType::Null;
|
||||
auto* entity = reinterpret_cast<const EntityBase*>(ps->tileElement);
|
||||
if (entity != nullptr)
|
||||
{
|
||||
entityType = entity->Type;
|
||||
}
|
||||
return entityType;
|
||||
}
|
||||
|
||||
static void PaintDrawStruct(paint_session& session, paint_struct* ps)
|
||||
{
|
||||
rct_drawpixelinfo* dpi = &session.DPI;
|
||||
|
@ -515,8 +506,7 @@ static void PaintDrawStruct(paint_session& session, paint_struct* ps)
|
|||
}
|
||||
}
|
||||
|
||||
auto entityType = GetEntityTypeFromPaintSession(ps);
|
||||
auto imageId = PaintPSColourifyImage(ps->image_id, ps->sprite_type, entityType, session.ViewFlags);
|
||||
auto imageId = PaintPSColourifyImage(ps->image_id, ps->sprite_type, session.ViewFlags, ps->tileElement, ps->entity);
|
||||
if (gPaintBoundingBoxes && dpi->zoom_level == ZoomLevel{ 0 })
|
||||
{
|
||||
PaintPSImageWithBoundingBoxes(dpi, ps, imageId, x, y);
|
||||
|
@ -566,8 +556,7 @@ static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t v
|
|||
{
|
||||
auto screenCoords = ScreenCoordsXY{ attached_ps->x + ps->x, attached_ps->y + ps->y };
|
||||
|
||||
auto entityType = GetEntityTypeFromPaintSession(ps);
|
||||
auto imageId = PaintPSColourifyImage(attached_ps->image_id, ps->sprite_type, entityType, viewFlags);
|
||||
auto imageId = PaintPSColourifyImage(attached_ps->image_id, ps->sprite_type, viewFlags, ps->tileElement, ps->entity);
|
||||
if (attached_ps->flags & PAINT_STRUCT_FLAG_IS_MASKED)
|
||||
{
|
||||
gfx_draw_sprite_raw_masked(dpi, screenCoords, imageId, attached_ps->colour_image_id);
|
||||
|
@ -676,19 +665,20 @@ static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId image
|
|||
}
|
||||
|
||||
static ImageId PaintPSColourifyImage(
|
||||
ImageId imageId, ViewportInteractionItem spriteType, EntityType entityType, uint32_t viewFlags)
|
||||
ImageId imageId, ViewportInteractionItem spriteType, uint32_t viewFlags, const TileElement* tileElement,
|
||||
const EntityBase* entity)
|
||||
{
|
||||
auto seeThrough = imageId.WithTransparancy(FilterPaletteID::PaletteDarken1);
|
||||
if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_RIDES)
|
||||
{
|
||||
if (spriteType == ViewportInteractionItem::Ride)
|
||||
{
|
||||
return seeThrough;
|
||||
return (viewFlags & VIEWPORT_FLAG_INVISIBLE_RIDES) ? ImageId() : seeThrough;
|
||||
}
|
||||
}
|
||||
if (viewFlags & VIEWPORT_FLAG_SEETHROUGH_VEHICLES)
|
||||
{
|
||||
if (spriteType == ViewportInteractionItem::Entity && entityType == EntityType::Vehicle)
|
||||
if (spriteType == ViewportInteractionItem::Entity && (entity != nullptr && entity->Type == EntityType::Vehicle))
|
||||
{
|
||||
return (viewFlags & VIEWPORT_FLAG_INVISIBLE_VEHICLES) ? ImageId() : seeThrough;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
struct EntityBase;
|
||||
struct TileElement;
|
||||
enum class RailingEntrySupportType : uint8_t;
|
||||
enum class ViewportInteractionItem : uint8_t;
|
||||
|
@ -50,6 +51,7 @@ struct paint_struct
|
|||
paint_struct* children;
|
||||
paint_struct* next_quadrant_ps;
|
||||
TileElement* tileElement;
|
||||
EntityBase* entity;
|
||||
ImageId image_id;
|
||||
ImageId colour_image_id;
|
||||
int32_t x;
|
||||
|
@ -192,7 +194,8 @@ struct PaintSessionCore
|
|||
paint_string_struct* LastPSString;
|
||||
attached_paint_struct* LastAttachedPS;
|
||||
const TileElement* SurfaceElement;
|
||||
const void* CurrentlyDrawnItem;
|
||||
EntityBase* CurrentlyDrawnEntity;
|
||||
TileElement* CurrentlyDrawnTileElement;
|
||||
const TileElement* PathElementOnSameHeight;
|
||||
const TileElement* TrackElementOnSameHeight;
|
||||
paint_struct* WoodenSupportsPrependTo;
|
||||
|
|
|
@ -165,7 +165,8 @@ paint_session* Painter::CreateSession(rct_drawpixelinfo* dpi, uint32_t viewFlags
|
|||
session->PSStringHead = nullptr;
|
||||
session->LastPSString = nullptr;
|
||||
session->WoodenSupportsPrependTo = nullptr;
|
||||
session->CurrentlyDrawnItem = nullptr;
|
||||
session->CurrentlyDrawnEntity = nullptr;
|
||||
session->CurrentlyDrawnTileElement = nullptr;
|
||||
session->SurfaceElement = nullptr;
|
||||
|
||||
return session;
|
||||
|
|
|
@ -481,13 +481,12 @@ bool wooden_a_supports_paint_setup(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_SUPPORTS)
|
||||
{
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
|
||||
|
@ -643,13 +642,12 @@ bool wooden_b_supports_paint_setup(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_SUPPORTS)
|
||||
{
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
|
||||
|
@ -818,13 +816,12 @@ bool metal_a_supports_paint_setup(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_SUPPORTS)
|
||||
{
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
imageColourFlags = ImageId(0).WithTransparancy(FilterPaletteID::PaletteDarken1).ToUInt32();
|
||||
}
|
||||
|
||||
|
@ -1022,13 +1019,12 @@ bool metal_b_supports_paint_setup(
|
|||
return false; // AND
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_SUPPORTS)
|
||||
{
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
imageColourFlags = ImageId(0).WithTransparancy(FilterPaletteID::PaletteDarken1).ToUInt32();
|
||||
}
|
||||
|
||||
|
@ -1207,13 +1203,12 @@ bool path_a_supports_paint_setup(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_SUPPORTS)
|
||||
{
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
|
||||
|
@ -1362,13 +1357,12 @@ bool path_b_supports_paint_setup(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_SUPPORTS)
|
||||
{
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
imageTemplate = ImageId().WithTransparancy(FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,9 +125,6 @@ static void PaintRideEntranceExit(paint_session& session, uint8_t direction, int
|
|||
return;
|
||||
}
|
||||
|
||||
if ((session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_RIDES) && (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_RIDES))
|
||||
return;
|
||||
|
||||
auto stationObj = ride->GetStationObject();
|
||||
if (stationObj == nullptr || stationObj->BaseImageId == ImageIndexUndefined)
|
||||
{
|
||||
|
|
|
@ -140,7 +140,7 @@ static void PaintTileElementBase(paint_session& session, const CoordsXY& origCoo
|
|||
session.MapPosition.x = coords.x;
|
||||
session.MapPosition.y = coords.y;
|
||||
|
||||
const TileElement* tile_element = map_get_first_element_at(session.MapPosition);
|
||||
auto* tile_element = map_get_first_element_at(session.MapPosition);
|
||||
if (tile_element == nullptr)
|
||||
return;
|
||||
uint8_t rotation = session.CurrentRotation;
|
||||
|
@ -263,7 +263,7 @@ static void PaintTileElementBase(paint_session& session, const CoordsXY& origCoo
|
|||
}
|
||||
|
||||
CoordsXY mapPosition = session.MapPosition;
|
||||
session.CurrentlyDrawnItem = tile_element;
|
||||
session.CurrentlyDrawnTileElement = tile_element;
|
||||
// Setup the painting of for example: the underground, signs, rides, scenery, etc.
|
||||
switch (tile_element->GetType())
|
||||
{
|
||||
|
|
|
@ -2195,9 +2195,6 @@ void PaintTrack(paint_session& session, Direction direction, int32_t height, con
|
|||
return;
|
||||
}
|
||||
|
||||
if ((session.ViewFlags & VIEWPORT_FLAG_SEETHROUGH_RIDES) && (session.ViewFlags & VIEWPORT_FLAG_INVISIBLE_RIDES))
|
||||
return;
|
||||
|
||||
if ((!gTrackDesignSaveMode || rideIndex == gTrackDesignSaveRideIndex)
|
||||
&& !(session.ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES))
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "../../interface/Viewport.h"
|
||||
#include "../../paint/Paint.h"
|
||||
#include "../../paint/Supports.h"
|
||||
#include "../../ride/Vehicle.h"
|
||||
#include "../Ride.h"
|
||||
#include "../RideEntry.h"
|
||||
#include "../Track.h"
|
||||
|
@ -18,8 +19,6 @@
|
|||
|
||||
static void PaintCircusTent(paint_session& session, const Ride& ride, uint8_t direction, int8_t al, int8_t cl, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
auto rideEntry = ride.GetRideEntry();
|
||||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
@ -28,7 +27,7 @@ static void PaintCircusTent(paint_session& session, const Ride& ride, uint8_t di
|
|||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
|
||||
auto imageTemplate = ImageId(0, ride.vehicle_colours[0].Body, ride.vehicle_colours[0].Trim);
|
||||
|
@ -42,7 +41,7 @@ static void PaintCircusTent(paint_session& session, const Ride& ride, uint8_t di
|
|||
PaintAddImageAsParent(
|
||||
session, imageTemplate.WithIndex(imageIndex), { al, cl, height + 3 }, { 24, 24, 47 }, { al + 16, cl + 16, height + 3 });
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "../../interface/Viewport.h"
|
||||
#include "../../paint/Paint.h"
|
||||
#include "../../paint/Supports.h"
|
||||
#include "../../ride/Vehicle.h"
|
||||
#include "../Ride.h"
|
||||
#include "../RideEntry.h"
|
||||
#include "../Track.h"
|
||||
|
@ -52,9 +53,11 @@ static constexpr const rct_crooked_house_bound_box crooked_house_data[] = {
|
|||
static void PaintCrookedHouseStructure(
|
||||
paint_session& session, uint8_t direction, int32_t x_offset, int32_t y_offset, uint32_t segment, int32_t height)
|
||||
{
|
||||
const TileElement* original_tile_element = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
const auto* tileElement = session.CurrentlyDrawnTileElement;
|
||||
if (tileElement == nullptr)
|
||||
return;
|
||||
|
||||
auto ride = get_ride(original_tile_element->AsTrack()->GetRideIndex());
|
||||
auto ride = get_ride(tileElement->AsTrack()->GetRideIndex());
|
||||
if (ride == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -68,7 +71,7 @@ static void PaintCrookedHouseStructure(
|
|||
if (vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,6 +81,8 @@ static void PaintCrookedHouseStructure(
|
|||
PaintAddImageAsParent(
|
||||
session, imageTemplate.WithIndex(imageIndex), { x_offset, y_offset, height + 3 }, { boundBox.length, 127 },
|
||||
{ boundBox.offset, height + 3 });
|
||||
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
}
|
||||
|
||||
static void PaintCrookedHouse(
|
||||
|
|
|
@ -66,8 +66,6 @@ static void PaintFerrisWheelRiders(
|
|||
static void PaintFerrisWheelStructure(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
auto rideEntry = ride.GetRideEntry();
|
||||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
@ -76,7 +74,7 @@ static void PaintFerrisWheelStructure(
|
|||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
|
||||
const auto& boundBox = FerrisWheelData[direction];
|
||||
|
@ -105,7 +103,7 @@ static void PaintFerrisWheelStructure(
|
|||
}
|
||||
PaintAddImageAsChild(session, rightSupportImageId, offset, bbLength, bbOffset);
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ static constexpr haunted_house_bound_box haunted_house_data[] = {
|
|||
static void PaintHauntedHouseStructure(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint8_t part, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
uint8_t frameNum = 0;
|
||||
|
||||
auto rideEntry = ride.GetRideEntry();
|
||||
|
@ -43,7 +41,7 @@ static void PaintHauntedHouseStructure(
|
|||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
frameNum = vehicle->Pitch;
|
||||
}
|
||||
|
||||
|
@ -63,7 +61,7 @@ static void PaintHauntedHouseStructure(
|
|||
{ boundBox.length.x, boundBox.length.y, 127 }, { boundBox.offset.x, boundBox.offset.y, height });
|
||||
}
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ static void PaintRiders(
|
|||
static void PaintCarousel(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
height += 7;
|
||||
|
||||
auto rideEntry = ride.GetRideEntry();
|
||||
|
@ -64,7 +63,7 @@ static void PaintCarousel(
|
|||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
|
||||
if (ride.lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)
|
||||
&& ride.breakdown_reason_pending == BREAKDOWN_CONTROL_FAILURE && ride.breakdown_sound_modifier >= 128)
|
||||
|
@ -96,7 +95,7 @@ static void PaintCarousel(
|
|||
|
||||
PaintRiders(session, ride, *rideEntry, *vehicle, rotationOffset, offset, bbLength, bbOffset);
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,6 @@ static constexpr const uint32_t space_rings_fence_sprites[] = {
|
|||
static void paint_space_rings_structure(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, uint32_t segment, int32_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
uint32_t vehicleIndex = (segment - direction) & 0x3;
|
||||
|
||||
if (ride.num_stations == 0 || vehicleIndex < ride.num_vehicles)
|
||||
|
@ -51,7 +49,7 @@ static void paint_space_rings_structure(
|
|||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
frameNum += static_cast<int8_t>(vehicle->Pitch) * 4;
|
||||
}
|
||||
|
||||
|
@ -82,7 +80,7 @@ static void paint_space_rings_structure(
|
|||
}
|
||||
}
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,11 @@
|
|||
#include "../RideEntry.h"
|
||||
#include "../Track.h"
|
||||
#include "../TrackPaint.h"
|
||||
#include "../Vehicle.h"
|
||||
|
||||
static void Paint3dCinemaDome(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
auto rideEntry = ride.GetRideEntry();
|
||||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
@ -28,7 +27,7 @@ static void Paint3dCinemaDome(
|
|||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && !ride.vehicles[0].IsNull())
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = GetEntity<Vehicle>(ride.vehicles[0]);
|
||||
session.CurrentlyDrawnEntity = GetEntity<Vehicle>(ride.vehicles[0]);
|
||||
}
|
||||
|
||||
auto imageTemplate = ImageId(0, ride.vehicle_colours[0].Body, ride.vehicle_colours[0].Trim);
|
||||
|
@ -42,7 +41,7 @@ static void Paint3dCinemaDome(
|
|||
PaintAddImageAsParent(
|
||||
session, imageId, { xOffset, yOffset, height + 3 }, { 24, 24, 47 }, { xOffset + 16, yOffset + 16, height + 3 });
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ static void PaintEnterpriseRiders(
|
|||
static void PaintEnterpriseStructure(
|
||||
paint_session& session, const Ride& ride, int8_t xOffset, int8_t yOffset, uint16_t height, const TrackElement& trackElement)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
const auto* rideEntry = get_ride_entry(ride.subtype);
|
||||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
@ -56,7 +55,7 @@ static void PaintEnterpriseStructure(
|
|||
if (vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +83,7 @@ static void PaintEnterpriseStructure(
|
|||
PaintEnterpriseRiders(session, *rideEntry, *vehicle, imageOffset, offset, bbLength, bbOffset);
|
||||
}
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ static ImageIndex GetMagicCarpetPendulumImage(Plane plane, Direction direction,
|
|||
return imageIndex;
|
||||
}
|
||||
|
||||
static const Vehicle* GetFirstVehicle(const Ride& ride)
|
||||
static Vehicle* GetFirstVehicle(const Ride& ride)
|
||||
{
|
||||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)
|
||||
{
|
||||
|
@ -193,15 +193,13 @@ static void PaintMagicCarpetVehicle(
|
|||
static void PaintMagicCarpetStructure(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
auto swing = 0;
|
||||
auto* vehicle = GetFirstVehicle(ride);
|
||||
if (vehicle != nullptr)
|
||||
{
|
||||
swing = vehicle->Pitch;
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
|
||||
bound_box bb = MagicCarpetBounds[direction];
|
||||
|
@ -222,8 +220,8 @@ static void PaintMagicCarpetStructure(
|
|||
PaintMagicCarpetPendulum(session, Plane::Front, swing, direction, offset, bbOffset, bbSize);
|
||||
PaintMagicCarpetFrame(session, Plane::Front, direction, offset, bbOffset, bbSize);
|
||||
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
}
|
||||
|
||||
static void PaintMagicCarpet(
|
||||
|
|
|
@ -37,7 +37,6 @@ static void PaintMotionSimulatorVehicle(
|
|||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
CoordsXYZ offset(offsetX, offsetY, height + 2);
|
||||
|
||||
Vehicle* vehicle = nullptr;
|
||||
|
@ -47,7 +46,7 @@ static void PaintMotionSimulatorVehicle(
|
|||
if (vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,7 @@ static void PaintMotionSimulatorVehicle(
|
|||
break;
|
||||
}
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ static constexpr const uint32_t SwingingInverterShipFrameSprites[] = {
|
|||
static void PaintSwingingInverterShipStructure(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
rct_ride_entry* rideEntry = get_ride_entry(ride.subtype);
|
||||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
@ -86,7 +84,7 @@ static void PaintSwingingInverterShipStructure(
|
|||
if (vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +128,7 @@ static void PaintSwingingInverterShipStructure(
|
|||
PaintAddImageAsChild(session, vehicleImageId, offset, bbLength, bbOffset);
|
||||
}
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,8 +94,6 @@ static void PaintSwingingShipRiders(
|
|||
static void PaintSwingingShipStructure(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
rct_ride_entry* rideEntry = get_ride_entry(ride.subtype);
|
||||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
@ -105,7 +103,7 @@ static void PaintSwingingShipStructure(
|
|||
{
|
||||
vehicle = GetEntity<Vehicle>(ride.vehicles[0]);
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
|
||||
const auto& bounds = SwingingShipData[direction];
|
||||
|
@ -157,7 +155,7 @@ static void PaintSwingingShipStructure(
|
|||
imageId = supportsImageTemplate.WithIndex(SwingingShipFrameSprites[(direction & 1)][1]);
|
||||
PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset);
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,18 +124,14 @@ static void PaintTopSpinVehicle(
|
|||
|
||||
const auto& vehicleEntry = rideEntry->vehicles[0];
|
||||
|
||||
// As we will be drawing a vehicle we need to backup the trackElement that
|
||||
// is assigned to the drawings.
|
||||
const TileElement* curTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
height += 3;
|
||||
uint8_t seatRotation = 0;
|
||||
uint8_t armRotation = 0;
|
||||
const auto* vehicle = GetEntity<Vehicle>(ride.vehicles[0]);
|
||||
auto* vehicle = GetEntity<Vehicle>(ride.vehicles[0]);
|
||||
if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr)
|
||||
{
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
|
||||
armRotation = vehicle->Pitch;
|
||||
seatRotation = vehicle->bank_rotation;
|
||||
|
@ -181,7 +177,7 @@ static void PaintTopSpinVehicle(
|
|||
imageIndex = vehicleEntry.base_image_id + 573 + ((direction & 1) << 1);
|
||||
PaintAddImageAsChild(session, supportImageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset);
|
||||
|
||||
session.CurrentlyDrawnItem = curTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
static void paint_twist_structure(
|
||||
paint_session& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint16_t height)
|
||||
{
|
||||
const TileElement* savedTileElement = static_cast<const TileElement*>(session.CurrentlyDrawnItem);
|
||||
|
||||
rct_ride_entry* rideEntry = get_ride_entry(ride.subtype);
|
||||
Vehicle* vehicle = nullptr;
|
||||
|
||||
|
@ -39,7 +37,7 @@ static void paint_twist_structure(
|
|||
vehicle = GetEntity<Vehicle>(ride.vehicles[0]);
|
||||
|
||||
session.InteractionType = ViewportInteractionItem::Entity;
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
session.CurrentlyDrawnEntity = vehicle;
|
||||
}
|
||||
|
||||
uint32_t frameNum = (direction * 88) % 216;
|
||||
|
@ -75,7 +73,7 @@ static void paint_twist_structure(
|
|||
}
|
||||
}
|
||||
|
||||
session.CurrentlyDrawnItem = savedTileElement;
|
||||
session.CurrentlyDrawnEntity = nullptr;
|
||||
session.InteractionType = ViewportInteractionItem::Ride;
|
||||
}
|
||||
|
||||
|
|
|
@ -1268,23 +1268,17 @@ void vehicle_visual_splash_boats_or_water_coaster(
|
|||
paint_session& session, int32_t x, int32_t imageDirection, int32_t y, int32_t z, const Vehicle* vehicle,
|
||||
const rct_ride_entry_vehicle* vehicleEntry)
|
||||
{
|
||||
if (vehicle->IsHead())
|
||||
{
|
||||
vehicle = GetEntity<Vehicle>(vehicle->next_vehicle_on_ride);
|
||||
}
|
||||
else
|
||||
{
|
||||
vehicle = GetEntity<Vehicle>(vehicle->prev_vehicle_on_ride);
|
||||
}
|
||||
if (vehicle == nullptr)
|
||||
auto* vehicleToPaint = vehicle->IsHead() ? GetEntity<Vehicle>(vehicle->next_vehicle_on_ride)
|
||||
: GetEntity<Vehicle>(vehicle->prev_vehicle_on_ride);
|
||||
if (vehicleToPaint == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
session.CurrentlyDrawnItem = vehicle;
|
||||
imageDirection = ((session.CurrentRotation * 8) + vehicle->sprite_direction) & 0x1F;
|
||||
session.SpritePosition.x = vehicle->x;
|
||||
session.SpritePosition.y = vehicle->y;
|
||||
|
||||
vehicle->Paint(session, imageDirection);
|
||||
session.CurrentlyDrawnEntity = vehicleToPaint;
|
||||
imageDirection = ((session.CurrentRotation * 8) + vehicle->sprite_direction) & 0x1F;
|
||||
session.SpritePosition.x = vehicleToPaint->x;
|
||||
session.SpritePosition.y = vehicleToPaint->y;
|
||||
vehicleToPaint->Paint(session, imageDirection);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -273,7 +273,7 @@ static uint8_t TestTrackElementPaintCalls(uint8_t rideType, uint8_t trackType, u
|
|||
gSurfaceElement = &surfaceElement;
|
||||
gDidPassSurface = true;
|
||||
|
||||
gPaintSession.CurrentlyDrawnItem = &tileElement;
|
||||
gPaintSession.CurrentlyDrawnTileElement = &tileElement;
|
||||
gPaintSession.SurfaceElement = &surfaceElement;
|
||||
gPaintSession.DidPassSurface = true;
|
||||
|
||||
|
@ -436,7 +436,7 @@ static uint8_t TestTrackElementSegmentSupportHeight(
|
|||
gSurfaceElement = &surfaceElement;
|
||||
gDidPassSurface = true;
|
||||
|
||||
gPaintSession.CurrentlyDrawnItem = &tileElement;
|
||||
gPaintSession.CurrentlyDrawnTileElement = &tileElement;
|
||||
gPaintSession.SurfaceElement = &surfaceElement;
|
||||
gPaintSession.DidPassSurface = true;
|
||||
|
||||
|
@ -523,7 +523,7 @@ static uint8_t TestTrackElementGeneralSupportHeight(
|
|||
gSurfaceElement = &surfaceElement;
|
||||
gDidPassSurface = true;
|
||||
|
||||
gPaintSession.CurrentlyDrawnItem = &tileElement;
|
||||
gPaintSession.CurrentlyDrawnTileElement = &tileElement;
|
||||
gPaintSession.SurfaceElement = &surfaceElement;
|
||||
gPaintSession.DidPassSurface = true;
|
||||
|
||||
|
@ -624,7 +624,7 @@ static uint8_t TestTrackElementSideTunnels(uint8_t rideType, uint8_t trackType,
|
|||
gSurfaceElement = &surfaceElement;
|
||||
gDidPassSurface = true;
|
||||
|
||||
gPaintSession.CurrentlyDrawnItem = &tileElement;
|
||||
gPaintSession.CurrentlyDrawnTileElement = &tileElement;
|
||||
gPaintSession.SurfaceElement = &surfaceElement;
|
||||
gPaintSession.DidPassSurface = true;
|
||||
|
||||
|
@ -752,7 +752,7 @@ static uint8_t TestTrackElementVerticalTunnels(uint8_t rideType, uint8_t trackTy
|
|||
gSurfaceElement = &surfaceElement;
|
||||
gDidPassSurface = true;
|
||||
|
||||
gPaintSession.CurrentlyDrawnItem = &tileElement;
|
||||
gPaintSession.CurrentlyDrawnTileElement = &tileElement;
|
||||
gPaintSession.SurfaceElement = &surfaceElement;
|
||||
gPaintSession.DidPassSurface = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue