Rename some fields in PaintStruct

This commit is contained in:
ζeh Matt 2023-04-14 03:06:53 +03:00
parent 63d15c71ae
commit 5ea09be0f8
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
5 changed files with 100 additions and 100 deletions

View File

@ -43,14 +43,14 @@ static void fixup_pointers(std::vector<RecordedPaintSession>& s)
auto& quadrants = s[i].Session.Quadrants;
for (size_t j = 0; j < entries.size(); j++)
{
if (entries[j].AsBasic()->next_quadrant_ps == reinterpret_cast<PaintStruct*>(-1))
if (entries[j].AsBasic()->NextQuadrantEntry == reinterpret_cast<PaintStruct*>(-1))
{
entries[j].AsBasic()->next_quadrant_ps = nullptr;
entries[j].AsBasic()->NextQuadrantEntry = nullptr;
}
else
{
auto nextQuadrantPs = reinterpret_cast<size_t>(entries[j].AsBasic()->next_quadrant_ps) / sizeof(PaintEntry);
entries[j].AsBasic()->next_quadrant_ps = s[i].Entries[nextQuadrantPs].AsBasic();
auto nextQuadrantPs = reinterpret_cast<size_t>(entries[j].AsBasic()->NextQuadrantEntry) / sizeof(PaintEntry);
entries[j].AsBasic()->NextQuadrantEntry = s[i].Entries[nextQuadrantPs].AsBasic();
}
}
for (size_t j = 0; j < std::size(quadrants); j++)
@ -160,7 +160,7 @@ static int command_line_for_bench_sprite_sort(int argc, const char** argv)
std::vector<RecordedPaintSession> sessions(1);
for (auto& ps : sessions[0].Entries)
{
ps.AsBasic()->next_quadrant_ps = reinterpret_cast<PaintStruct*>(-1);
ps.AsBasic()->NextQuadrantEntry = reinterpret_cast<PaintStruct*>(-1);
}
for (auto& quad : sessions[0].Session.Quadrants)
{

View File

@ -73,9 +73,9 @@ uint8_t gCurrentRotation;
static uint32_t _currentImageType;
InteractionInfo::InteractionInfo(const PaintStruct* ps)
: Loc(ps->map_x, ps->map_y)
, Element(ps->tileElement)
, Entity(ps->entity)
, SpriteType(ps->sprite_type)
, Element(ps->Element)
, Entity(ps->Entity)
, SpriteType(ps->InteractionItem)
{
}
static void ViewportPaintWeatherGloom(DrawPixelInfo& dpi);
@ -879,7 +879,7 @@ static void RecordSession(
// Remap all entries
for (auto& ps : recordedSession.Entries)
{
auto& ptr = ps.AsBasic()->next_quadrant_ps;
auto& ptr = ps.AsBasic()->NextQuadrantEntry;
auto it = entryRemap.find(ptr);
if (it == entryRemap.end())
{
@ -1416,12 +1416,12 @@ static bool IsTileElementVegetation(const TileElement* tileElement)
VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlags)
{
switch (ps->sprite_type)
switch (ps->InteractionItem)
{
case ViewportInteractionItem::Entity:
if (ps->entity != nullptr)
if (ps->Entity != nullptr)
{
switch (ps->entity->Type)
switch (ps->Entity->Type)
{
case EntityType::Vehicle:
{
@ -1434,7 +1434,7 @@ VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlag
// these should be hidden if 'hide rides' is enabled
if (viewFlags & VIEWPORT_FLAG_HIDE_RIDES)
{
auto vehicle = ps->entity->As<Vehicle>();
auto vehicle = ps->Entity->As<Vehicle>();
if (vehicle == nullptr)
break;
@ -1481,9 +1481,9 @@ VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlag
case ViewportInteractionItem::Scenery:
case ViewportInteractionItem::LargeScenery:
case ViewportInteractionItem::Wall:
if (ps->tileElement != nullptr)
if (ps->Element != nullptr)
{
if (IsTileElementVegetation(ps->tileElement))
if (IsTileElementVegetation(ps->Element))
{
if (viewFlags & VIEWPORT_FLAG_HIDE_VEGETATION)
{
@ -1499,7 +1499,7 @@ VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlag
}
}
}
if (ps->sprite_type == ViewportInteractionItem::Wall && (viewFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE))
if (ps->InteractionItem == ViewportInteractionItem::Wall && (viewFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE))
{
return VisibilityKind::Partial;
}
@ -1515,10 +1515,10 @@ VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlag
*/
static bool PSSpriteTypeIsInFilter(PaintStruct* ps, uint16_t filter)
{
if (ps->sprite_type != ViewportInteractionItem::None && ps->sprite_type != ViewportInteractionItem::Label
&& ps->sprite_type <= ViewportInteractionItem::Banner)
if (ps->InteractionItem != ViewportInteractionItem::None && ps->InteractionItem != ViewportInteractionItem::Label
&& ps->InteractionItem <= ViewportInteractionItem::Banner)
{
auto mask = EnumToFlag(ps->sprite_type);
auto mask = EnumToFlag(ps->InteractionItem);
if (filter & mask)
{
return true;
@ -1837,7 +1837,7 @@ InteractionInfo SetInteractionInfoFromPaintSession(PaintSession* session, uint32
PaintStruct* ps = &session->PaintHead;
InteractionInfo info{};
while ((ps = ps->next_quadrant_ps) != nullptr)
while ((ps = ps->NextQuadrantEntry) != nullptr)
{
PaintStruct* old_ps = ps;
PaintStruct* next_ps = ps;
@ -1851,12 +1851,12 @@ InteractionInfo SetInteractionInfoFromPaintSession(PaintSession* session, uint32
info = { ps };
}
}
next_ps = ps->children;
next_ps = ps->Children;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnull-dereference"
for (AttachedPaintStruct* attached_ps = ps->attached_ps; attached_ps != nullptr; attached_ps = attached_ps->next)
for (AttachedPaintStruct* attached_ps = ps->Attached; attached_ps != nullptr; attached_ps = attached_ps->next)
{
if (IsSpriteInteractedWith(
session->DPI, attached_ps->image_id, { (attached_ps->x + ps->x), (attached_ps->y + ps->y) }))

View File

@ -64,8 +64,8 @@ static int32_t RemapPositionToQuadrant(const PaintStruct& ps, uint8_t rotation)
constexpr auto MapRangeMax = MaxPaintQuadrants * COORDS_XY_STEP;
constexpr auto MapRangeCenter = MapRangeMax / 2;
const auto x = ps.bounds.x;
const auto y = ps.bounds.y;
const auto x = ps.Bounds.x;
const auto y = ps.Bounds.y;
// NOTE: We are not calling CoordsXY::Rotate on purpose to mix in the additional
// value without a secondary switch.
switch (rotation & 3)
@ -92,8 +92,8 @@ static void PaintSessionAddPSToQuadrant(PaintSession& session, PaintStruct* ps)
// Values below zero or above MaxPaintQuadrants are void, corners also share the same quadrant as void.
const uint32_t paintQuadrantIndex = std::clamp(positionHash / COORDS_XY_STEP, 0, MaxPaintQuadrants - 1);
ps->quadrant_index = paintQuadrantIndex;
ps->next_quadrant_ps = session.Quadrants[paintQuadrantIndex];
ps->QuadrantIndex = paintQuadrantIndex;
ps->NextQuadrantEntry = session.Quadrants[paintQuadrantIndex];
session.Quadrants[paintQuadrantIndex] = ps;
session.QuadrantBackIndex = std::min(session.QuadrantBackIndex, paintQuadrantIndex);
@ -180,19 +180,19 @@ static PaintStruct* CreateNormalPaintStruct(
ps->image_id = image_id;
ps->x = imagePos.x;
ps->y = imagePos.y;
ps->bounds.x_end = rotBoundBoxSize.x + rotBoundBoxOffset.x + session.SpritePosition.x;
ps->bounds.y_end = rotBoundBoxSize.y + rotBoundBoxOffset.y + session.SpritePosition.y;
ps->bounds.z_end = rotBoundBoxSize.z + rotBoundBoxOffset.z;
ps->bounds.x = rotBoundBoxOffset.x + session.SpritePosition.x;
ps->bounds.y = rotBoundBoxOffset.y + session.SpritePosition.y;
ps->bounds.z = rotBoundBoxOffset.z;
ps->attached_ps = nullptr;
ps->children = nullptr;
ps->sprite_type = session.InteractionType;
ps->Bounds.x_end = rotBoundBoxSize.x + rotBoundBoxOffset.x + session.SpritePosition.x;
ps->Bounds.y_end = rotBoundBoxSize.y + rotBoundBoxOffset.y + session.SpritePosition.y;
ps->Bounds.z_end = rotBoundBoxSize.z + rotBoundBoxOffset.z;
ps->Bounds.x = rotBoundBoxOffset.x + session.SpritePosition.x;
ps->Bounds.y = rotBoundBoxOffset.y + session.SpritePosition.y;
ps->Bounds.z = rotBoundBoxOffset.z;
ps->Attached = nullptr;
ps->Children = nullptr;
ps->InteractionItem = session.InteractionType;
ps->map_x = session.MapPosition.x;
ps->map_y = session.MapPosition.y;
ps->tileElement = session.CurrentlyDrawnTileElement;
ps->entity = session.CurrentlyDrawnEntity;
ps->Element = session.CurrentlyDrawnTileElement;
ps->Entity = session.CurrentlyDrawnEntity;
return ps;
}
@ -315,10 +315,10 @@ static PaintStruct* PaintStructsFirstInQuadrant(PaintStruct* psNext, uint16_t qu
do
{
ps = psNext;
psNext = psNext->next_quadrant_ps;
psNext = psNext->NextQuadrantEntry;
if (psNext == nullptr)
return ps;
} while (quadrantIndex > psNext->quadrant_index);
} while (quadrantIndex > psNext->QuadrantIndex);
return ps;
}
@ -326,26 +326,26 @@ static void PaintStructsInitializeSort(PaintStruct* ps, uint16_t quadrantIndex,
{
do
{
ps = ps->next_quadrant_ps;
ps = ps->NextQuadrantEntry;
if (ps == nullptr)
break;
if (ps->quadrant_index > quadrantIndex + 1)
if (ps->QuadrantIndex > quadrantIndex + 1)
{
// Outside of the range.
ps->SortFlags = PaintSortFlags::OutsideQuadrant;
}
else if (ps->quadrant_index == quadrantIndex + 1)
else if (ps->QuadrantIndex == quadrantIndex + 1)
{
// Is neighbour and requires a visit.
ps->SortFlags = PaintSortFlags::Neighbour | PaintSortFlags::PendingVisit;
}
else if (ps->quadrant_index == quadrantIndex)
else if (ps->QuadrantIndex == quadrantIndex)
{
// In specified quadrant, requires visit.
ps->SortFlags = flag | PaintSortFlags::PendingVisit;
}
} while (ps->quadrant_index <= quadrantIndex + 1);
} while (ps->QuadrantIndex <= quadrantIndex + 1);
}
static std::pair<PaintStruct*, PaintStruct*> PaintStructsGetNextPending(PaintStruct* ps)
@ -353,7 +353,7 @@ static std::pair<PaintStruct*, PaintStruct*> PaintStructsGetNextPending(PaintStr
PaintStruct* ps_next;
while (true)
{
ps_next = ps->next_quadrant_ps;
ps_next = ps->NextQuadrantEntry;
if (ps_next == nullptr)
{
// End of the current list.
@ -380,11 +380,11 @@ template<uint8_t TRotation> static void PaintStructsSortQuadrant(PaintStruct* pa
child->SortFlags &= ~PaintSortFlags::PendingVisit;
// Compare all the children below the first child and move them up in the list if they intersect.
const PaintStructBoundBox& initialBBox = child->bounds;
const PaintStructBoundBox& initialBBox = child->Bounds;
for (;;)
{
auto* ps = child;
child = child->next_quadrant_ps;
child = child->NextQuadrantEntry;
if (child == nullptr || child->SortFlags & PaintSortFlags::OutsideQuadrant)
{
@ -396,15 +396,15 @@ template<uint8_t TRotation> static void PaintStructsSortQuadrant(PaintStruct* pa
continue;
}
if (CheckBoundingBox<TRotation>(initialBBox, child->bounds))
if (CheckBoundingBox<TRotation>(initialBBox, child->Bounds))
{
// Child node intersects with current node, move behind.
ps->next_quadrant_ps = child->next_quadrant_ps;
ps->NextQuadrantEntry = child->NextQuadrantEntry;
auto* psTemp = parent->next_quadrant_ps;
parent->next_quadrant_ps = child;
auto* psTemp = parent->NextQuadrantEntry;
parent->NextQuadrantEntry = child;
child->next_quadrant_ps = psTemp;
child->NextQuadrantEntry = psTemp;
child = ps;
}
}
@ -444,7 +444,7 @@ static PaintStruct* PaintArrangeStructsHelperRotation(PaintStruct* psQuadrantEnt
static void PaintStructsLinkQuadrants(PaintSessionCore& session)
{
PaintStruct* ps = &session.PaintHead;
ps->next_quadrant_ps = nullptr;
ps->NextQuadrantEntry = nullptr;
uint32_t quadrantIndex = session.QuadrantBackIndex;
do
@ -452,11 +452,11 @@ static void PaintStructsLinkQuadrants(PaintSessionCore& session)
PaintStruct* psNext = session.Quadrants[quadrantIndex];
if (psNext != nullptr)
{
ps->next_quadrant_ps = psNext;
ps->NextQuadrantEntry = psNext;
do
{
ps = psNext;
psNext = psNext->next_quadrant_ps;
psNext = psNext->NextQuadrantEntry;
} while (psNext != nullptr);
}
@ -506,7 +506,7 @@ static void PaintDrawStruct(PaintSession& session, PaintStruct* ps)
auto x = ps->x;
auto y = ps->y;
if (ps->sprite_type == ViewportInteractionItem::Entity)
if (ps->InteractionItem == ViewportInteractionItem::Entity)
{
if (session.DPI.zoom_level >= ZoomLevel{ 1 })
{
@ -530,9 +530,9 @@ static void PaintDrawStruct(PaintSession& session, PaintStruct* ps)
GfxDrawSprite(session.DPI, imageId, { x, y });
}
if (ps->children != nullptr)
if (ps->Children != nullptr)
{
PaintDrawStruct(session, ps->children);
PaintDrawStruct(session, ps->Children);
}
else
{
@ -550,11 +550,11 @@ void PaintDrawStructs(PaintSession& session)
PaintStruct* ps = &session.PaintHead;
for (ps = ps->next_quadrant_ps; ps != nullptr;)
for (ps = ps->NextQuadrantEntry; ps != nullptr;)
{
PaintDrawStruct(session, ps);
ps = ps->next_quadrant_ps;
ps = ps->NextQuadrantEntry;
}
}
@ -565,7 +565,7 @@ void PaintDrawStructs(PaintSession& session)
*/
static void PaintAttachedPS(DrawPixelInfo& dpi, PaintStruct* ps, uint32_t viewFlags)
{
AttachedPaintStruct* attached_ps = ps->attached_ps;
AttachedPaintStruct* attached_ps = ps->Attached;
for (; attached_ps != nullptr; attached_ps = attached_ps->next)
{
auto screenCoords = ScreenCoordsXY{ attached_ps->x + ps->x, attached_ps->y + ps->y };
@ -584,62 +584,62 @@ static void PaintAttachedPS(DrawPixelInfo& dpi, PaintStruct* ps, uint32_t viewFl
static void PaintPSImageWithBoundingBoxes(DrawPixelInfo& dpi, PaintStruct* ps, ImageId imageId, int32_t x, int32_t y)
{
const uint8_t colour = BoundBoxDebugColours[EnumValue(ps->sprite_type)];
const uint8_t colour = BoundBoxDebugColours[EnumValue(ps->InteractionItem)];
const uint8_t rotation = GetCurrentRotation();
const CoordsXYZ frontTop = {
ps->bounds.x_end,
ps->bounds.y_end,
ps->bounds.z_end,
ps->Bounds.x_end,
ps->Bounds.y_end,
ps->Bounds.z_end,
};
const auto screenCoordFrontTop = Translate3DTo2DWithZ(rotation, frontTop);
const CoordsXYZ frontBottom = {
ps->bounds.x_end,
ps->bounds.y_end,
ps->bounds.z,
ps->Bounds.x_end,
ps->Bounds.y_end,
ps->Bounds.z,
};
const auto screenCoordFrontBottom = Translate3DTo2DWithZ(rotation, frontBottom);
const CoordsXYZ leftTop = {
ps->bounds.x,
ps->bounds.y_end,
ps->bounds.z_end,
ps->Bounds.x,
ps->Bounds.y_end,
ps->Bounds.z_end,
};
const auto screenCoordLeftTop = Translate3DTo2DWithZ(rotation, leftTop);
const CoordsXYZ leftBottom = {
ps->bounds.x,
ps->bounds.y_end,
ps->bounds.z,
ps->Bounds.x,
ps->Bounds.y_end,
ps->Bounds.z,
};
const auto screenCoordLeftBottom = Translate3DTo2DWithZ(rotation, leftBottom);
const CoordsXYZ rightTop = {
ps->bounds.x_end,
ps->bounds.y,
ps->bounds.z_end,
ps->Bounds.x_end,
ps->Bounds.y,
ps->Bounds.z_end,
};
const auto screenCoordRightTop = Translate3DTo2DWithZ(rotation, rightTop);
const CoordsXYZ rightBottom = {
ps->bounds.x_end,
ps->bounds.y,
ps->bounds.z,
ps->Bounds.x_end,
ps->Bounds.y,
ps->Bounds.z,
};
const auto screenCoordRightBottom = Translate3DTo2DWithZ(rotation, rightBottom);
const CoordsXYZ backTop = {
ps->bounds.x,
ps->bounds.y,
ps->bounds.z_end,
ps->Bounds.x,
ps->Bounds.y,
ps->Bounds.z_end,
};
const auto screenCoordBackTop = Translate3DTo2DWithZ(rotation, backTop);
const CoordsXYZ backBottom = {
ps->bounds.x,
ps->bounds.y,
ps->bounds.z,
ps->Bounds.x,
ps->Bounds.y,
ps->Bounds.z,
};
const auto screenCoordBackBottom = Translate3DTo2DWithZ(rotation, backBottom);
@ -782,7 +782,7 @@ PaintStruct* PaintAddImageAsChild(
return nullptr;
}
parentPS->children = ps;
parentPS->Children = ps;
return ps;
}
@ -847,8 +847,8 @@ bool PaintAttachToPreviousPS(PaintSession& session, const ImageId image_id, int3
ps->y = y;
ps->IsMasked = false;
AttachedPaintStruct* oldFirstAttached = masterPs->attached_ps;
masterPs->attached_ps = ps;
AttachedPaintStruct* oldFirstAttached = masterPs->Attached;
masterPs->Attached = ps;
ps->next = oldFirstAttached;
return true;

View File

@ -48,20 +48,20 @@ struct PaintStructBoundBox
struct PaintStruct
{
PaintStructBoundBox bounds;
AttachedPaintStruct* attached_ps;
PaintStruct* children;
PaintStruct* next_quadrant_ps;
TileElement* tileElement;
EntityBase* entity;
PaintStructBoundBox Bounds;
AttachedPaintStruct* Attached;
PaintStruct* Children;
PaintStruct* NextQuadrantEntry;
TileElement* Element;
EntityBase* Entity;
ImageId image_id;
int32_t x;
int32_t y;
int32_t map_x;
int32_t map_y;
uint16_t quadrant_index;
uint16_t QuadrantIndex;
uint8_t SortFlags;
ViewportInteractionItem sprite_type;
ViewportInteractionItem InteractionItem;
};
struct PaintStringStruct

View File

@ -596,7 +596,7 @@ bool WoodenASupportsPaintSetup(
auto* ps = PaintAddImageAsOrphan(session, imageId, { 0, 0, z }, bBox);
if (ps != nullptr)
{
session.WoodenSupportsPrependTo->children = ps;
session.WoodenSupportsPrependTo->Children = ps;
}
}
}
@ -768,7 +768,7 @@ bool WoodenBSupportsPaintSetup(
_9E32B1 = true;
if (paintStruct != nullptr)
{
session.WoodenSupportsPrependTo->children = paintStruct;
session.WoodenSupportsPrependTo->Children = paintStruct;
}
}
}
@ -1296,7 +1296,7 @@ bool PathASupportsPaintSetup(
hasSupports = true;
if (paintStruct != nullptr)
{
session.WoodenSupportsPrependTo->children = paintStruct;
session.WoodenSupportsPrependTo->Children = paintStruct;
}
}
}