feat(region): add SRgnIsRectInRegionf

This commit is contained in:
Adam Heinermann 2025-04-21 19:26:24 -07:00 committed by fallenoak
parent d322f579a2
commit c143493110
3 changed files with 105 additions and 0 deletions

View file

@ -541,3 +541,30 @@ int32_t SRgnIsPointInRegionf(HSRGN handle, float x, float y) {
s_rgntable.Unlock(lockedHandle);
return result;
}
int32_t SRgnIsRectInRegionf(HSRGN handle, const RECTF* rect) {
STORM_VALIDATE_BEGIN;
STORM_VALIDATE(handle);
STORM_VALIDATE(rect);
STORM_VALIDATE_END;
HLOCKEDRGN lockedHandle;
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
if (!rgn) return 0;
int32_t result = 0;
SOURCE* sourceArray = rgn->source.Ptr();
uint32_t sourceRects = rgn->source.Count();
for (uint32_t i = 0; i < sourceRects; i++) {
if (!(sourceArray[i].flags & SF_PARAMONLY)) {
if (CheckForIntersection(rect, &sourceArray[i].rect)) {
result = 1;
break;
}
}
}
s_rgntable.Unlock(lockedHandle);
return result;
}

View file

@ -22,5 +22,7 @@ void SRgnGetRectsf(HSRGN handle, uint32_t* numRects, RECTF* buffer);
int32_t SRgnIsPointInRegionf(HSRGN handle, float x, float y);
int32_t SRgnIsRectInRegionf(HSRGN handle, const RECTF* rect);
#endif