MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / CreateNormalPaintStruct

Function CreateNormalPaintStruct

src/openrct2/paint/Paint.cpp:177–223  ·  view source on GitHub ↗

* Extracted from 0x0098196c, 0x0098197c, 0x0098198c, 0x0098199c */

Source from the content-addressed store, hash-verified

175 * Extracted from 0x0098196c, 0x0098197c, 0x0098198c, 0x0098199c
176 */
177static PaintStruct* CreateNormalPaintStruct(
178 PaintSession& session, ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox)
179{
180 auto* const g1 = GfxGetG1Element(image_id);
181 if (g1 == nullptr)
182 {
183 return nullptr;
184 }
185
186 const auto swappedRotation = DirectionFlipXAxis(session.CurrentRotation);
187 auto swappedRotCoord = CoordsXYZ{ offset.Rotate(swappedRotation), offset.z };
188 swappedRotCoord += session.SpritePosition;
189
190 const auto imagePos = Translate3DTo2DWithZ(session.CurrentRotation, swappedRotCoord);
191
192 if (!imageWithinRT(imagePos, *g1, session.rt))
193 {
194 return nullptr;
195 }
196
197 const auto rotBoundBoxOffset = CoordsXYZ{ boundBox.offset.Rotate(swappedRotation), boundBox.offset.z };
198 const auto rotBoundBoxSize = RotateBoundBoxSize(boundBox.length, session.CurrentRotation);
199
200 auto* ps = session.AllocateNormalPaintEntry();
201 if (ps == nullptr)
202 {
203 return nullptr;
204 }
205
206 ps->image_id = image_id;
207 ps->ScreenPos = imagePos;
208 ps->Bounds.x_end = rotBoundBoxSize.x + rotBoundBoxOffset.x + session.SpritePosition.x;
209 ps->Bounds.y_end = rotBoundBoxSize.y + rotBoundBoxOffset.y + session.SpritePosition.y;
210 ps->Bounds.z_end = rotBoundBoxSize.z + rotBoundBoxOffset.z;
211 ps->Bounds.x = rotBoundBoxOffset.x + session.SpritePosition.x;
212 ps->Bounds.y = rotBoundBoxOffset.y + session.SpritePosition.y;
213 ps->Bounds.z = rotBoundBoxOffset.z;
214 ps->Attached = nullptr;
215 ps->Children = nullptr;
216 ps->NextQuadrantEntry = nullptr;
217 ps->InteractionItem = session.InteractionType;
218 ps->MapPos = session.MapPosition;
219 ps->Element = session.CurrentlyDrawnTileElement;
220 ps->Entity = session.CurrentlyDrawnEntity;
221
222 return ps;
223}
224
225static PaintStruct* CreateNormalPaintStructHeight(
226 PaintSession& session, const ImageId imageId, const int32_t height, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox)

Callers 3

PaintAddImageAsParentFunction · 0.85
PaintAddImageAsOrphanFunction · 0.85
PaintAddImageAsChildFunction · 0.85

Calls 7

GfxGetG1ElementFunction · 0.85
DirectionFlipXAxisFunction · 0.85
Translate3DTo2DWithZFunction · 0.85
imageWithinRTFunction · 0.85
RotateBoundBoxSizeFunction · 0.85
RotateMethod · 0.45

Tested by

no test coverage detected