WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   What's the most performant way to draw unit frame health bar? (https://www.wowinterface.com/forums/showthread.php?t=56112)

Ethly 03-19-18 03:51 AM

What's the most performant way to draw unit frame health bar?
 
I want to display unit frame with health, incoming heal, heal absorb, damage absorb, and health deficit. Basically it's 5 adjacent rectangles with different colors. Currently I'm considering 3 different implementations and I don't know which one would be the most performant.

1. Put 4 statusbars for every value and one texture below for health deficit. All statusbars will be fixed, frame levels will be adjusted for proper z-order.

2. Put 4 textures for every value and one texture below. Textures will have fixed left side and Lua will change their width. With something like textureSublevel they will have proper z-order.

3. Put 5 textures one after other using anchors. They will have the same level, but they won't overlap, so it's not a problem.

3-rd variant looks like the best one, because game won't have to redraw pixels multiple times and theoretically could render textures simultaneously, but it seems significantly harder to implement with Lua (because I have to hide unused textures and rearrange their anchors all the time). Also I'm not sure if this layout mechanism performant enough.

jukx 03-19-18 05:22 AM

1. and 2. definitely don't seem to be the way to go. You'd have to recalculate the absorb bar width every time the health amount changes i.e. at each regen tick.

Your 3rd option comes close to how oUF suggests doing it which also looks sensible to me.

Lua Code:
  1. -- Position and size
  2.     local myBar = CreateFrame('StatusBar', nil, self.Health)
  3.     myBar:SetPoint('TOP')
  4.     myBar:SetPoint('BOTTOM')
  5.     myBar:SetPoint('LEFT', self.Health:GetStatusBarTexture(), 'RIGHT')
  6.     myBar:SetWidth(200)
  7.     local otherBar = CreateFrame('StatusBar', nil, self.Health)
  8.     otherBar:SetPoint('TOP')
  9.     otherBar:SetPoint('BOTTOM')
  10.     otherBar:SetPoint('LEFT', myBar:GetStatusBarTexture(), 'RIGHT')
  11.     otherBar:SetWidth(200)
  12.     local absorbBar = CreateFrame('StatusBar', nil, self.Health)
  13.     absorbBar:SetPoint('TOP')
  14.     absorbBar:SetPoint('BOTTOM')
  15.     absorbBar:SetPoint('LEFT', otherBar:GetStatusBarTexture(), 'RIGHT')
  16.     absorbBar:SetWidth(200)
  17.     local healAbsorbBar = CreateFrame('StatusBar', nil, self.Health)
  18.     healAbsorbBar:SetPoint('TOP')
  19.     healAbsorbBar:SetPoint('BOTTOM')
  20.     healAbsorbBar:SetPoint('RIGHT', self.Health:GetStatusBarTexture())
  21.     healAbsorbBar:SetWidth(200)
  22.     healAbsorbBar:SetReverseFill(true)

Although to save some calculations please do use a 100% width texture below the whole bar for the deficit.

Quote:

(because I have to hide unused textures and rearrange their anchors all the time)
Well you'd only have to set their anchors once, WoW does the moving behind the scenes (in an optimized fashion, one would hope). Also, aren't textures with width 0 (or empty statusbars) invisible by default?


All times are GMT -6. The time now is 08:17 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI