MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / IsPointWithinClx

Function IsPointWithinClx

Source/engine/render/clx_render.cpp:464–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464bool IsPointWithinClx(Point position, ClxSprite clx)
465{
466 const uint8_t *src = clx.pixelData();
467 const uint8_t *end = src + clx.pixelDataSize();
468 const uint16_t width = clx.width();
469
470 int xCur = 0;
471 int yCur = clx.height() - 1;
472 while (src < end) {
473 if (yCur != position.y) {
474 SkipSize skipSize {};
475 skipSize.xOffset = xCur;
476 src = SkipRestOfLineWithOverrun(src, width, skipSize);
477 yCur -= skipSize.wholeLines;
478 xCur = skipSize.xOffset;
479 if (yCur < position.y)
480 return false;
481 continue;
482 }
483
484 while (xCur < width) {
485 uint8_t val = *src++;
486 if (!IsClxOpaque(val)) {
487 // ignore transparent
488 xCur += val;
489 if (xCur > position.x)
490 return false;
491 continue;
492 }
493
494 if (IsClxOpaqueFill(val)) {
495 val = GetClxOpaqueFillWidth(val);
496 const uint8_t color = *src++;
497 if (xCur <= position.x && position.x < xCur + val)
498 return color != 0; // ignore shadows
499 xCur += val;
500 } else {
501 val = GetClxOpaquePixelsWidth(val);
502 for (uint8_t pixel = 0; pixel < val; pixel++) {
503 const uint8_t color = *src++;
504 if (xCur == position.x)
505 return color != 0; // ignore shadows
506 xCur++;
507 }
508 }
509 }
510
511 return false;
512 }
513
514 return false;
515}
516
517std::pair<int, int> ClxMeasureSolidHorizontalBounds(ClxSprite clx)
518{

Callers

nothing calls this directly

Calls 9

IsClxOpaqueFunction · 0.85
IsClxOpaqueFillFunction · 0.85
GetClxOpaqueFillWidthFunction · 0.85
GetClxOpaquePixelsWidthFunction · 0.85
pixelDataMethod · 0.80
pixelDataSizeMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected