Isle
Loading...
Searching...
No Matches
mxregion.h
Go to the documentation of this file.
1#ifndef __MXREGION_H
2#define __MXREGION_H
3
4#include "decomp.h"
5#include "mxcore.h"
6#include "mxgeometry.h"
7#include "mxlist.h"
8
9// SIZE 0x08
13class MxSegment {
14protected:
17
18public:
24 MxSegment(MxS32 p_min, MxS32 p_max)
25 {
26 m_min = p_min;
27 m_max = p_max;
28 }
29
34 MxS32 GetMin() { return m_min; }
35
40 MxS32 GetMax() { return m_max; }
41
46 MxSegment* Clone() { return new MxSegment(m_min, m_max); }
47
54
60 MxBool Adjacent(MxSegment& p_seg) { return m_max == p_seg.m_min || m_min == p_seg.m_max; }
61
67 MxBool IntersectsH(MxRect32& p_rect) { return p_rect.GetRight() > m_min && p_rect.GetTop() < m_max; }
68
74 MxBool operator==(MxSegment& p_seg) { return m_min == p_seg.m_min && m_max == p_seg.m_max; }
75
81 MxBool operator!=(MxSegment& p_seg) { return !operator==(p_seg); }
82};
83
84// VTABLE: LEGO1 0x100dcc40
85// VTABLE: BETA10 0x101c2628
86// class MxCollection<MxSegment *>
87
88// VTABLE: LEGO1 0x100dcc58
89// VTABLE: BETA10 0x101c2610
90// class MxList<MxSegment *>
91
92// VTABLE: LEGO1 0x100dcc70
93// VTABLE: BETA10 0x101c25f8
94// class MxPtrList<MxSegment>
95
96// VTABLE: LEGO1 0x100dcc88
97// VTABLE: BETA10 0x101c25e0
98// SIZE 0x18
102class MxSegmentList : public MxPtrList<MxSegment> {
103public:
108
109 // SYNTHETIC: LEGO1 0x100c4e90
110 // SYNTHETIC: BETA10 0x1014c1a0
111 // MxSegmentList::`scalar deleting destructor'
112};
113
114// VTABLE: LEGO1 0x100dcbf8
115// VTABLE: BETA10 0x101c25b0
116// class MxPtrListCursor<MxSegment>
117
118// VTABLE: LEGO1 0x100dcc28
119// VTABLE: BETA10 0x101c25c8
120// class MxListCursor<MxSegment *>
121
122// VTABLE: LEGO1 0x100dcc10
123// VTABLE: BETA10 0x101c2598
127class MxSegmentListCursor : public MxPtrListCursor<MxSegment> {
128public:
134};
135
136// SIZE 0x0c
141class MxSpan {
142protected:
146
147public:
153 MxSpan(MxS32 p_min, MxS32 p_max);
154
159 MxSpan(MxRect32& p_rect);
160
164 ~MxSpan() { delete m_segList; }
165
169 MxS32 GetMin() { return m_min; }
170
175 void SetMin(MxS32 p_min) { m_min = p_min; }
176
180 MxS32 GetMax() { return m_max; }
181
186 void SetMax(MxS32 p_max) { m_max = p_max; }
187
192 MxSpan* Clone();
193
197 void Compact();
198
205
211 MxBool Adjacent(MxSpan& p_span) { return m_max == p_span.m_min || m_min == p_span.m_max; }
212
219
225 MxBool IntersectsV(MxRect32& p_rect) { return p_rect.GetBottom() > m_min && p_rect.GetTop() < m_max; }
226
232 MxBool IntersectsH(MxRect32& p_rect);
233
239 void AddSegment(MxS32 p_min, MxS32 p_max);
240
247 {
248 return m_min == p_span.m_min && m_max == p_span.m_max && HasSameSegments(p_span);
249 }
250
256 MxBool operator!=(MxSpan& p_span) { return !operator==(p_span); }
257
258 friend class MxRegionCursor;
259
260 // SYNTHETIC: BETA10 0x1014b0b0
261 // MxSpan::`scalar deleting destructor'
262};
263
264// VTABLE: LEGO1 0x100dcb10
265// VTABLE: BETA10 0x101c24f8
266// class MxCollection<MxSpan *>
267
268// VTABLE: LEGO1 0x100dcb28
269// VTABLE: BETA10 0x101c24e0
270// class MxList<MxSpan *>
271
272// VTABLE: LEGO1 0x100dcb40
273// VTABLE: BETA10 0x101c24c8
274// class MxPtrList<MxSpan>
275
276// VTABLE: LEGO1 0x100dcb58
277// VTABLE: BETA10 0x101c24b0
278// SIZE 0x18
282class MxSpanList : public MxPtrList<MxSpan> {
283public:
288
289 // SYNTHETIC: LEGO1 0x100c3410
290 // SYNTHETIC: BETA10 0x1014af90
291 // MxSpanList::`scalar deleting destructor'
292};
293
294// VTABLE: LEGO1 0x100dcb70
295// VTABLE: BETA10 0x101c2528
296// class MxPtrListCursor<MxSpan>
297
298// VTABLE: LEGO1 0x100dcba0
299// VTABLE: BETA10 0x101c2540
300// class MxListCursor<MxSpan *>
301
302// TODO: The initialize list param type should be MxSpanList, but doing that
303// drastically reduced the match percentage for MxRegion::AddRect.
304// (developer provided MxRegion.h file also uses MxSpanList*.)
305// It also works with MxPtrList, so we'll do that until we figure this out.
306
307// VTABLE: LEGO1 0x100dcb88
308// VTABLE: BETA10 0x101c2510
312class MxSpanListCursor : public MxPtrListCursor<MxSpan> {
313public:
319};
320
321// VTABLE: LEGO1 0x100dcae8
322// SIZE 0x1c
327class MxRegion : public MxCore {
328protected:
331
332public:
336 MxRegion();
337
341 ~MxRegion() override;
342
347
351 virtual void Reset(); // vtable+0x14
352
357 virtual void AddRect(MxRect32& p_rect); // vtable+0x18
358
364 virtual MxBool Intersects(MxRect32& p_rect); // vtable+0x1c
365
369 virtual MxBool IsEmpty() { return m_spanList->GetNumElements() == 0; } // vtable+0x20
370
374 void Compact();
375
376 friend class MxRegionCursor;
377
378 // SYNTHETIC: LEGO1 0x100c3670
379 // SYNTHETIC: BETA10 0x1014b230
380 // MxRegion::`scalar deleting destructor'
381};
382
383// VTABLE: LEGO1 0x100dcbb8
384// SIZE 0x18
389class MxRegionCursor : public MxCore {
390protected:
395
400 void CreateSegmentListCursor(MxSegmentList* p_segList);
401
409 void SetRect(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom);
410
415 void NextSpan(MxRect32& p_rect);
416
421 void PrevSpan(MxRect32& p_rect);
422
423public:
428 MxRegionCursor(MxRegion* p_region);
429
433 ~MxRegionCursor() override;
434
439 virtual MxRect32* Head(); // vtable+0x18
440
445 virtual MxRect32* Tail(); // vtable+0x20
446
451 virtual MxRect32* Next(); // vtable+0x28
452
457 virtual MxRect32* Prev(); // vtable+0x30
458
464 virtual MxRect32* Head(MxRect32& p_rect); // vtable+0x14
465
471 virtual MxRect32* Tail(MxRect32& p_rect); // vtable+0x1c
472
478 virtual MxRect32* Next(MxRect32& p_rect); // vtable+0x24
479
485 virtual MxRect32* Prev(MxRect32& p_rect); // vtable+0x2c
486
491 virtual MxRect32* GetRect() { return m_rect; } // vtable+0x34
492
497 virtual MxBool Valid() { return m_rect != NULL; } // vtable+0x38
498
502 virtual void Reset(); // vtable+0x3c
503
504 // SYNTHETIC: LEGO1 0x100c4090
505 // MxRegionCursor::`scalar deleting destructor'
506};
507
508#ifdef REGION_SANITY_CHECK
509
513class MxRectIntersection {
514protected:
515 MxRect32 m_rect;
516 MxS32 m_numRects;
517
518public:
523 MxRect32& GetRect() { return m_rect; }
524
529 void SetRect(MxRect32& p_rect) { m_rect = p_rect; }
530
535 MxS32 GetNumRects() { return m_numRects; }
536
541 void SetNumRects(MxS32 p_numRects) { m_numRects = p_numRects; }
542};
543
547class MxRectIntersectionList : public MxPtrList<MxRectIntersection> {
548public:
552 MxRectIntersectionList() : MxPtrList<MxRectIntersection>(TRUE) {}
553};
554
558class MxRectIntersectionListCursor : public MxPtrListCursor<MxRectIntersection> {
559public:
564 MxRectIntersectionListCursor(MxRectIntersectionList* p_list) : MxPtrListCursor<MxRectIntersection>(p_list) {}
565};
566
570class MxRegionSanityCheck {
571protected:
572 MxRectIntersectionList* m_rectIntersectionList;
573
574public:
578 MxRegionSanityCheck();
579
583 ~MxRegionSanityCheck();
584
588 void Reset() { m_rectIntersectionList->Delete(); }
589
594 void AddRect(MxRect32& p_rect);
595
600 MxS32 CalculateArea();
601};
602
603#endif
604
605#endif // __MXREGION_H
[AI] Base virtual class for all Mindscape engine (Mx) objects.
Definition: mxcore.h:15
MxU32 GetNumElements()
[AI]
Definition: mxlist.h:118
[AI]
Definition: mxlist.h:148
[AI] Rectangle using 32-bit signed integer coordinates.
Definition: mxgeometry.h:706
T GetTop() const
[AI] Get the top edge.
Definition: mxgeometry.h:231
T GetRight() const
[AI] Get the right edge.
Definition: mxgeometry.h:241
T GetBottom() const
[AI] Get the bottom edge.
Definition: mxgeometry.h:251
[AI] Cursor object suitable for traversing all rectangles covered by an MxRegion.
Definition: mxregion.h:389
void PrevSpan(MxRect32 &p_rect)
[AI] Step to the previous span (reverse traversal) intersecting p_rect.
Definition: mxregion.cpp:365
virtual void Reset()
[AI] Resets the cursor(s) to the initial (uninitialized) state.
Definition: mxregion.cpp:295
virtual MxRect32 * Prev()
[AI] Steps backward to and returns the previous rectangle in region sequence.
Definition: mxregion.cpp:204
virtual MxBool Valid()
[AI] Checks if the cursor is currently referencing a valid rectangle (not at end).
Definition: mxregion.h:497
void SetRect(MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom)
[AI] Initializes or updates m_rect with the specified coordinates.
Definition: mxregion.cpp:321
MxRegion * m_region
[AI] The region being traversed. [AI]
Definition: mxregion.h:391
MxSegmentListCursor * m_segListCursor
[AI] Cursor for the current segment list. [AI]
Definition: mxregion.h:394
virtual MxRect32 * Head()
[AI] Seeks to and returns the first (topmost, leftmost) rectangle covered by the region.
Definition: mxregion.cpp:137
void CreateSegmentListCursor(MxSegmentList *p_segList)
[AI] Allocates a segment list cursor for the given segment list, replacing any previous segment curso...
Definition: mxregion.cpp:311
MxSpanListCursor * m_spanListCursor
[AI] Cursor for moving through the span list. [AI]
Definition: mxregion.h:393
MxRect32 * m_rect
[AI] Current rectangle being referenced. [AI]
Definition: mxregion.h:392
void NextSpan(MxRect32 &p_rect)
[AI] Step to the next span which overlaps p_rect (for filtered/region-clip traversal).
Definition: mxregion.cpp:334
virtual MxRect32 * GetRect()
[AI] Returns a pointer to the currently referenced rectangle.
Definition: mxregion.h:491
~MxRegionCursor() override
[AI] Destructor; releases ownership of current rectangle and cursors.
Definition: mxregion.cpp:121
virtual MxRect32 * Next()
[AI] Advances to and returns the next rectangle in region sequence.
Definition: mxregion.cpp:179
virtual MxRect32 * Tail()
[AI] Seeks to and returns the last (bottommost, rightmost) rectangle covered by the region.
Definition: mxregion.cpp:158
[AI] Represents a 2D region as a set of vertical spans each containing one or more horizontal segment...
Definition: mxregion.h:327
virtual void Reset()
[AI] Removes all spans and resets the bounding rectangle to an empty state.
Definition: mxregion.cpp:27
MxRect32 & GetBoundingRect()
[AI] Returns a reference to the current bounding rectangle for the region.
Definition: mxregion.h:346
MxSpanList * m_spanList
[AI] List of vertical spans for the region. [AI]
Definition: mxregion.h:329
void Compact()
[AI] Compacts the region's internal structure, merging adjacent/overlapping spans and segments when p...
MxRegion()
[AI] Constructs an (initially empty) region.
Definition: mxregion.cpp:12
virtual void AddRect(MxRect32 &p_rect)
[AI] Adds a rectangle to this region, merging or splitting spans and segments as necessary.
Definition: mxregion.cpp:35
~MxRegion() override
[AI] Destructor; destroys all spans and contained segments.
Definition: mxregion.cpp:20
virtual MxBool IsEmpty()
[AI] Returns TRUE if the region contains zero spans (i.e., is empty).
Definition: mxregion.h:369
virtual MxBool Intersects(MxRect32 &p_rect)
[AI] Checks if this region intersects with a given rectangle (any overlap between the region's covere...
Definition: mxregion.cpp:88
MxRect32 m_boundingRect
[AI] Cached bounding rectangle for the whole region. [AI]
Definition: mxregion.h:330
[AI] Cursor for traversing an MxSegmentList; allows sequential access through the segments.
Definition: mxregion.h:127
MxSegmentListCursor(MxSegmentList *p_list)
[AI] Constructs a cursor to navigate the given segment list.
Definition: mxregion.h:133
[AI] List container for segments; stores pointers to MxSegment objects and may take ownership dependi...
Definition: mxregion.h:102
MxSegmentList()
[AI] Constructs a segment list that takes ownership and deletes segments on destruction/removal.
Definition: mxregion.h:107
[AI] Represents a 1D segment defined by a minimum and maximum integer value.
Definition: mxregion.h:13
MxBool Combine(MxSegment &p_seg)
[AI] Attempt to merge this segment with the specified segment, if they are adjacent or overlapping.
MxBool IntersectsH(MxRect32 &p_rect)
[AI] Determines if this segment horizontally intersects a given rectangle, interpreted as an interval...
Definition: mxregion.h:67
MxS32 m_min
[AI] Lower boundary of the segment (inclusive). [AI]
Definition: mxregion.h:15
MxS32 m_max
[AI] Upper boundary of the segment (exclusive). [AI]
Definition: mxregion.h:16
MxSegment * Clone()
[AI] Creates a copy of the current segment.
Definition: mxregion.h:46
MxS32 GetMin()
[AI] Returns the lower boundary of the segment (inclusive).
Definition: mxregion.h:34
MxBool Adjacent(MxSegment &p_seg)
[AI] Checks if this segment is adjacent to another (i.e., ends where the other begins or vice versa).
Definition: mxregion.h:60
MxBool operator!=(MxSegment &p_seg)
[AI] Inequality operator: checks if this segment differs from the specified segment by its boundaries...
Definition: mxregion.h:81
MxBool operator==(MxSegment &p_seg)
[AI] Equality operator: checks if this segment has identical boundaries to the specified segment.
Definition: mxregion.h:74
MxSegment(MxS32 p_min, MxS32 p_max)
[AI] Constructs a new segment with the specified minimum and maximum boundaries.
Definition: mxregion.h:24
MxS32 GetMax()
[AI] Returns the upper boundary of the segment (exclusive).
Definition: mxregion.h:40
[AI] Cursor for traversing an MxSpanList, to sequentially access all spans in the list.
Definition: mxregion.h:312
MxSpanListCursor(MxPtrList< MxSpan > *p_list)
[AI] Cursor for any list of span pointers.
Definition: mxregion.h:318
[AI] List container for spans; holds MxSpan pointers and may automatically destroy them.
Definition: mxregion.h:282
MxSpanList()
[AI] Constructs a new span list which owns its entries.
Definition: mxregion.h:287
[AI] Represents a vertical span—a 1D range plus a set of contained horizontal segments,...
Definition: mxregion.h:141
MxS32 m_max
[AI] Upper vertical boundary (usually 'bottom'). [AI]
Definition: mxregion.h:144
void Compact()
[AI] Compact this span, potentially merging adjacent or overlapping segments for optimal storage.
MxS32 GetMax()
[AI] Returns the vertical upper boundary of the span.
Definition: mxregion.h:180
~MxSpan()
[AI] Destructor; releases the segment list and owned segments inside this span.
Definition: mxregion.h:164
MxS32 GetMin()
[AI] Returns the vertical lower boundary of the span.
Definition: mxregion.h:169
MxBool IntersectsH(MxRect32 &p_rect)
[AI] Checks if any segment in this span horizontally overlaps with the given rectangle.
Definition: mxregion.cpp:480
MxBool operator==(MxSpan &p_span)
[AI] Tests for equality (vertical bounds and segments) with another span.
Definition: mxregion.h:246
void AddSegment(MxS32 p_min, MxS32 p_max)
[AI] Adds a horizontal segment to this span, merging with adjacent segments if required to maintain c...
Definition: mxregion.cpp:417
MxBool Adjacent(MxSpan &p_span)
[AI] Checks if this span is vertically adjacent to another (end-to-end).
Definition: mxregion.h:211
void SetMin(MxS32 p_min)
[AI] Sets the vertical lower boundary of the span.
Definition: mxregion.h:175
void SetMax(MxS32 p_max)
[AI] Sets the vertical upper boundary of the span.
Definition: mxregion.h:186
MxSegmentList * m_segList
[AI] List of horizontal segments covered by this vertical span. [AI]
Definition: mxregion.h:145
MxSpan * Clone()
[AI] Deep copies this span, including all its attached segments.
Definition: mxregion.cpp:464
MxBool Combine(MxSpan &p_span)
[AI] Tries to merge this span with another, if possible (must be adjacent and have matching segments)...
MxBool HasSameSegments(MxSpan &p_span)
[AI] Checks for pointwise segment equivalence between two spans.
MxBool IntersectsV(MxRect32 &p_rect)
[AI] Check if this span vertically intersects a rectangle (vertical ranges overlap).
Definition: mxregion.h:225
MxBool operator!=(MxSpan &p_span)
[AI] Tests for inequality with another span.
Definition: mxregion.h:256
MxS32 m_min
[AI] Lower vertical boundary (usually 'top'). [AI]
Definition: mxregion.h:143
#define TRUE
Definition: d3drmdef.h:28
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
signed int MxS32
[AI]
Definition: mxtypes.h:38