mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-04 00:49:08 +00:00
feat(region): add SRgnIsPointInRegionf
This commit is contained in:
parent
a5c55bc803
commit
d322f579a2
3 changed files with 82 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue