feat(region): add SRgnIsPointInRegionf

This commit is contained in:
Adam Heinermann 2025-04-21 18:50:31 -07:00 committed by fallenoak
parent a5c55bc803
commit d322f579a2
3 changed files with 82 additions and 0 deletions

View file

@ -514,3 +514,30 @@ void SRgnGetRectsf(HSRGN handle, uint32_t* numRects, RECTF* buffer) {
s_rgntable.Unlock(lockedHandle);
}
int32_t SRgnIsPointInRegionf(HSRGN handle, float x, float y) {
STORM_VALIDATE_BEGIN;
STORM_VALIDATE(handle);
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 (x >= sourceArray[i].rect.left && y >= sourceArray[i].rect.bottom &&
x < sourceArray[i].rect.right && y < sourceArray[i].rect.top) {
result = 1;
break;
}
}
}
s_rgntable.Unlock(lockedHandle);
return result;
}

View file

@ -20,4 +20,7 @@ void SRgnGetRectParamsf(HSRGN handle, RECTF* rect, uint32_t* numParams, void** b
void SRgnGetRectsf(HSRGN handle, uint32_t* numRects, RECTF* buffer);
int32_t SRgnIsPointInRegionf(HSRGN handle, float x, float y);
#endif