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

Function DrawObject

Source/engine/render/scrollrt.cpp:493–526  ·  view source on GitHub ↗

* @brief Render an object sprite * @param out Output buffer * @param tilePosition dPiece coordinates * @param targetBufferPosition Output buffer coordinates * @param pre Is the sprite in the background */

Source from the content-addressed store, hash-verified

491 * @param pre Is the sprite in the background
492 */
493void DrawObject(const Surface &out, Point tilePosition, Point targetBufferPosition, bool pre)
494{
495 if (LightTableIndex >= LightsMax) {
496 return;
497 }
498
499 Object *object = FindObjectAtPosition(tilePosition);
500 if (object == nullptr) {
501 return;
502 }
503
504 const Object &objectToDraw = *object;
505 if (objectToDraw._oPreFlag != pre) {
506 return;
507 }
508
509 const ClxSprite sprite = (*objectToDraw._oAnimData)[objectToDraw._oAnimFrame - 1];
510
511 Point screenPosition = targetBufferPosition - Displacement { CalculateWidth2(sprite.width()), 0 };
512 if (objectToDraw.position != tilePosition) {
513 // drawing a large or offset object, calculate the correct position for the center of the sprite
514 Displacement worldOffset = objectToDraw.position - tilePosition;
515 screenPosition -= worldOffset.worldToScreen();
516 }
517
518 if (&objectToDraw == ObjectUnderCursor) {
519 ClxDrawOutlineSkipColorZero(out, 194, screenPosition, sprite);
520 }
521 if (objectToDraw.applyLighting) {
522 ClxDrawLight(out, screenPosition, sprite, LightTableIndex);
523 } else {
524 ClxDraw(out, screenPosition, sprite);
525 }
526}
527
528static void DrawDungeon(const Surface & /*out*/, Point /*tilePosition*/, Point /*targetBufferPosition*/);
529

Callers 1

DrawDungeonFunction · 0.85

Calls 7

FindObjectAtPositionFunction · 0.85
CalculateWidth2Function · 0.85
ClxDrawLightFunction · 0.85
ClxDrawFunction · 0.85
widthMethod · 0.80
worldToScreenMethod · 0.80

Tested by

no test coverage detected