mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor paint vehicle to ImageId
This commit is contained in:
parent
b83f7c3859
commit
6cbf87cab3
|
@ -929,69 +929,72 @@ const vehicle_boundbox VehicleBoundboxes[16][224] = {
|
|||
}
|
||||
};
|
||||
|
||||
static void PaintVehicleRiders(
|
||||
paint_session* session, const Vehicle* vehicle, const rct_ride_entry_vehicle* vehicleEntry, uint32_t baseImageId, int32_t z,
|
||||
const vehicle_boundbox& bb)
|
||||
{
|
||||
baseImageId += vehicleEntry->no_vehicle_images;
|
||||
for (auto i = 0; i < 8; i++)
|
||||
{
|
||||
if (vehicle->num_peeps > (i * 2) && vehicleEntry->no_seating_rows > i)
|
||||
{
|
||||
auto offsetImageId = baseImageId;
|
||||
if (i == 0 && (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_RIDER_ANIMATION))
|
||||
{
|
||||
offsetImageId += (vehicleEntry->no_vehicle_images * vehicle->animation_frame);
|
||||
}
|
||||
|
||||
auto peepColour0 = vehicle->peep_tshirt_colours[i * 2];
|
||||
auto peepColour1 = vehicle->peep_tshirt_colours[(i * 2) + 1];
|
||||
auto imageId = ImageId(offsetImageId, peepColour0, peepColour1);
|
||||
if (vehicle->IsGhost())
|
||||
{
|
||||
imageId = ImageId(offsetImageId).WithRemap(FilterPaletteID::Palette44);
|
||||
}
|
||||
|
||||
PaintAddImageAsChild(
|
||||
session, imageId, { 0, 0, z }, { bb.length_x, bb.length_y, bb.length_z },
|
||||
{ bb.offset_x, bb.offset_y, bb.offset_z + z });
|
||||
baseImageId += vehicleEntry->no_vehicle_images;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 6D5214
|
||||
static void vehicle_sprite_paint(
|
||||
paint_session* session, const Vehicle* vehicle, int32_t ebx, int32_t ecx, int32_t z,
|
||||
const rct_ride_entry_vehicle* vehicleEntry)
|
||||
{
|
||||
int32_t baseImage_id = ebx;
|
||||
if (vehicleEntry->draw_order >= std::size(VehicleBoundboxes))
|
||||
{
|
||||
return;
|
||||
}
|
||||
vehicle_boundbox bb = VehicleBoundboxes[vehicleEntry->draw_order][ecx];
|
||||
|
||||
const auto& bb = VehicleBoundboxes[vehicleEntry->draw_order][ecx];
|
||||
|
||||
auto baseImageId = static_cast<uint32_t>(ebx);
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES)
|
||||
{
|
||||
baseImage_id += (vehicle->spin_sprite / 8) & 31;
|
||||
baseImageId += (vehicle->spin_sprite / 8) & 31;
|
||||
}
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION)
|
||||
{
|
||||
baseImage_id += vehicle->animation_frame;
|
||||
baseImageId += vehicle->animation_frame;
|
||||
}
|
||||
int32_t image_id = baseImage_id | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24)
|
||||
| IMAGE_TYPE_REMAP_2_PLUS;
|
||||
|
||||
auto imageId = ImageId(baseImageId, vehicle->colours.body_colour, vehicle->colours.trim_colour, vehicle->colours_extended);
|
||||
if (vehicle->IsGhost())
|
||||
{
|
||||
image_id &= 0x7FFFF;
|
||||
image_id |= CONSTRUCTION_MARKER;
|
||||
imageId = ImageId(baseImageId).WithRemap(FilterPaletteID::Palette44);
|
||||
}
|
||||
paint_struct* ps = PaintAddImageAsParent(
|
||||
session, image_id, { 0, 0, z }, { bb.length_x, bb.length_y, bb.length_z },
|
||||
PaintAddImageAsParent(
|
||||
session, imageId, { 0, 0, z }, { bb.length_x, bb.length_y, bb.length_z },
|
||||
{ bb.offset_x, bb.offset_y, bb.offset_z + z });
|
||||
if (ps != nullptr)
|
||||
{
|
||||
ps->tertiary_colour = vehicle->colours_extended;
|
||||
}
|
||||
rct_drawpixelinfo* dpi = &session->DPI;
|
||||
|
||||
auto* dpi = &session->DPI;
|
||||
if (dpi->zoom_level < ZoomLevel{ 2 } && vehicle->num_peeps > 0 && vehicleEntry->no_seating_rows > 0)
|
||||
{
|
||||
baseImage_id += vehicleEntry->no_vehicle_images;
|
||||
for (int32_t i = 0; i < 8; i++)
|
||||
{
|
||||
if (vehicle->num_peeps > (i * 2) && vehicleEntry->no_seating_rows > i)
|
||||
{
|
||||
image_id = baseImage_id
|
||||
| SPRITE_ID_PALETTE_COLOUR_2(
|
||||
vehicle->peep_tshirt_colours[i * 2], vehicle->peep_tshirt_colours[(i * 2) + 1]);
|
||||
if (i == 0 && vehicleEntry->flags & VEHICLE_ENTRY_FLAG_RIDER_ANIMATION)
|
||||
{
|
||||
image_id += (vehicleEntry->no_vehicle_images * vehicle->animation_frame);
|
||||
}
|
||||
|
||||
if (vehicle->IsGhost())
|
||||
{
|
||||
image_id &= 0x7FFFF;
|
||||
image_id |= CONSTRUCTION_MARKER;
|
||||
}
|
||||
|
||||
PaintAddImageAsChild(
|
||||
session, image_id, 0, 0, bb.length_x, bb.length_y, bb.length_z, z, bb.offset_x, bb.offset_y,
|
||||
bb.offset_z + z);
|
||||
baseImage_id += vehicleEntry->no_vehicle_images;
|
||||
}
|
||||
}
|
||||
PaintVehicleRiders(session, vehicle, vehicleEntry, baseImageId, z, bb);
|
||||
}
|
||||
vehicle_visual_splash_effect(session, z, vehicle, vehicleEntry);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,38 @@ enum
|
|||
SPR_OBSERVATION_TOWER_SEGMENT_TOP = 14988,
|
||||
};
|
||||
|
||||
static uint32_t GetObservationTowerVehicleBaseImageId(
|
||||
const Vehicle* vehicle, const rct_ride_entry_vehicle* vehicleEntry, int32_t imageDirection)
|
||||
{
|
||||
uint32_t result = (vehicle->restraints_position / 64);
|
||||
if (vehicle->restraints_position >= 64)
|
||||
{
|
||||
auto directionOffset = imageDirection / 8;
|
||||
if ((directionOffset == 0) || (directionOffset == 3))
|
||||
{
|
||||
result = vehicleEntry->base_image_id + 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
result *= 2;
|
||||
result += vehicleEntry->base_image_id;
|
||||
if (directionOffset == 1)
|
||||
{
|
||||
result += 28;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += 22;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (vehicle->animation_frame * 2) + vehicleEntry->base_image_id + 8;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006D6258
|
||||
|
@ -33,53 +65,19 @@ void vehicle_visual_observation_tower(
|
|||
paint_session* session, int32_t x, int32_t imageDirection, int32_t y, int32_t z, const Vehicle* vehicle,
|
||||
const rct_ride_entry_vehicle* vehicleEntry)
|
||||
{
|
||||
int32_t image_id;
|
||||
int32_t baseImage_id = (vehicle->restraints_position / 64);
|
||||
if (vehicle->restraints_position >= 64)
|
||||
{
|
||||
auto directionOffset = imageDirection / 8;
|
||||
if ((directionOffset == 0) || (directionOffset == 3))
|
||||
{
|
||||
baseImage_id = vehicleEntry->base_image_id + 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseImage_id *= 2;
|
||||
baseImage_id += vehicleEntry->base_image_id;
|
||||
if (directionOffset == 1)
|
||||
{
|
||||
baseImage_id += 28;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseImage_id += 22;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
baseImage_id = (vehicle->animation_frame * 2) + vehicleEntry->base_image_id + 8;
|
||||
}
|
||||
|
||||
image_id = baseImage_id | SPRITE_ID_PALETTE_COLOUR_3(vehicle->colours.body_colour, vehicle->colours.trim_colour);
|
||||
auto baseImageId = GetObservationTowerVehicleBaseImageId(vehicle, vehicleEntry, imageDirection);
|
||||
auto imageId0 = ImageId(
|
||||
baseImageId + 0, vehicle->colours.body_colour, vehicle->colours.trim_colour, vehicle->colours_extended);
|
||||
auto imageId1 = ImageId(
|
||||
baseImageId + 1, vehicle->colours.body_colour, vehicle->colours.trim_colour, vehicle->colours_extended);
|
||||
if (vehicle->IsGhost())
|
||||
{
|
||||
image_id = (image_id & 0x7FFFF) | CONSTRUCTION_MARKER;
|
||||
}
|
||||
paint_struct* ps = PaintAddImageAsParent(session, image_id, { 0, 0, z }, { 2, 2, 41 }, { -11, -11, z + 1 });
|
||||
if (ps != nullptr)
|
||||
{
|
||||
ps->tertiary_colour = vehicle->colours_extended;
|
||||
}
|
||||
|
||||
image_id++;
|
||||
|
||||
ps = PaintAddImageAsParent(session, image_id, { 0, 0, z }, { 16, 16, 41 }, { -5, -5, z + 1 });
|
||||
if (ps != nullptr)
|
||||
{
|
||||
ps->tertiary_colour = vehicle->colours_extended;
|
||||
imageId0 = ImageId(baseImageId + 0).WithRemap(FilterPaletteID::Palette44);
|
||||
imageId1 = ImageId(baseImageId + 1).WithRemap(FilterPaletteID::Palette44);
|
||||
}
|
||||
|
||||
PaintAddImageAsParent(session, imageId0, { 0, 0, z }, { 2, 2, 41 }, { -11, -11, z + 1 });
|
||||
PaintAddImageAsParent(session, imageId1, { 0, 0, z }, { 16, 16, 41 }, { -5, -5, z + 1 });
|
||||
assert(vehicleEntry->effect_visual == 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,37 @@
|
|||
#include "../Vehicle.h"
|
||||
#include "../VehiclePaint.h"
|
||||
|
||||
#ifndef NO_VEHICLES
|
||||
static uint32_t SubmarineVehicleGetBaseImageId(
|
||||
const Vehicle* vehicle, const rct_ride_entry_vehicle* vehicleEntry, int32_t imageDirection)
|
||||
{
|
||||
uint32_t result = imageDirection;
|
||||
if (vehicle->restraints_position >= 64)
|
||||
{
|
||||
if ((vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION) && !(imageDirection & 3))
|
||||
{
|
||||
result /= 8;
|
||||
result += ((vehicle->restraints_position - 64) / 64) * 4;
|
||||
result *= vehicleEntry->base_num_frames;
|
||||
result += vehicleEntry->restraint_image_id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES)
|
||||
{
|
||||
result /= 2;
|
||||
}
|
||||
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_USE_4_ROTATION_FRAMES)
|
||||
{
|
||||
result /= 8;
|
||||
}
|
||||
result *= vehicleEntry->base_num_frames;
|
||||
result += vehicleEntry->base_image_id;
|
||||
result += vehicle->SwingSprite;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006D44D5
|
||||
|
@ -25,61 +55,25 @@ void vehicle_visual_submarine(
|
|||
paint_session* session, int32_t x, int32_t imageDirection, int32_t y, int32_t z, const Vehicle* vehicle,
|
||||
const rct_ride_entry_vehicle* vehicleEntry)
|
||||
{
|
||||
auto imageFlags = SPRITE_ID_PALETTE_COLOUR_3(vehicle->colours.body_colour, vehicle->colours.trim_colour);
|
||||
auto baseImageId = SubmarineVehicleGetBaseImageId(vehicle, vehicleEntry, imageDirection);
|
||||
auto imageId0 = ImageId(
|
||||
baseImageId + 0, vehicle->colours.body_colour, vehicle->colours.trim_colour, vehicle->colours_extended);
|
||||
auto imageId1 = ImageId(
|
||||
baseImageId + 1, vehicle->colours.body_colour, vehicle->colours.trim_colour, vehicle->colours_extended);
|
||||
if (vehicle->IsGhost())
|
||||
{
|
||||
imageFlags = CONSTRUCTION_MARKER;
|
||||
imageId0 = ImageId(baseImageId + 0).WithRemap(FilterPaletteID::Palette44);
|
||||
imageId1 = ImageId(baseImageId + 1).WithRemap(FilterPaletteID::Palette44);
|
||||
}
|
||||
|
||||
int32_t baseImage_id = imageDirection;
|
||||
int32_t image_id;
|
||||
if (vehicle->restraints_position >= 64)
|
||||
{
|
||||
if ((vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION) && !(imageDirection & 3))
|
||||
{
|
||||
baseImage_id /= 8;
|
||||
baseImage_id += ((vehicle->restraints_position - 64) / 64) * 4;
|
||||
baseImage_id *= vehicleEntry->base_num_frames;
|
||||
baseImage_id += vehicleEntry->restraint_image_id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES)
|
||||
{
|
||||
baseImage_id /= 2;
|
||||
}
|
||||
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_USE_4_ROTATION_FRAMES)
|
||||
{
|
||||
baseImage_id /= 8;
|
||||
}
|
||||
baseImage_id *= vehicleEntry->base_num_frames;
|
||||
baseImage_id += vehicleEntry->base_image_id;
|
||||
baseImage_id += vehicle->SwingSprite;
|
||||
}
|
||||
|
||||
vehicle_boundbox bb = VehicleBoundboxes[vehicleEntry->draw_order][imageDirection / 2];
|
||||
|
||||
image_id = baseImage_id | imageFlags;
|
||||
paint_struct* ps = PaintAddImageAsParent(
|
||||
session, image_id, { 0, 0, z }, { bb.length_x, bb.length_y, bb.length_z },
|
||||
const auto& bb = VehicleBoundboxes[vehicleEntry->draw_order][imageDirection / 2];
|
||||
PaintAddImageAsParent(
|
||||
session, imageId0, { 0, 0, z }, { bb.length_x, bb.length_y, bb.length_z },
|
||||
{ bb.offset_x, bb.offset_y, bb.offset_z + z });
|
||||
if (ps != nullptr)
|
||||
{
|
||||
ps->tertiary_colour = vehicle->colours_extended;
|
||||
}
|
||||
|
||||
image_id = (baseImage_id + 1) | imageFlags;
|
||||
ps = PaintAddImageAsParent(
|
||||
session, image_id, { 0, 0, z }, { bb.length_x, bb.length_y, 2 }, { bb.offset_x, bb.offset_y, bb.offset_z + z - 10 });
|
||||
if (ps != nullptr)
|
||||
{
|
||||
ps->tertiary_colour = vehicle->colours_extended;
|
||||
}
|
||||
|
||||
PaintAddImageAsParent(
|
||||
session, imageId1, { 0, 0, z }, { bb.length_x, bb.length_y, 2 }, { bb.offset_x, bb.offset_y, bb.offset_z + z - 10 });
|
||||
assert(vehicleEntry->effect_visual == 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void submarine_ride_paint_track_station(
|
||||
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
|
||||
|
|
Loading…
Reference in New Issue