View Single Post
06-29-13, 03:16 AM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Alright, I wrote a small proof of concept that demonstrates just how much of a difference hiding the frame before you reposition it makes, even if it makes no visible difference in-game.
Lua Code:
  1. local Nameplates, PreviousWorldChildren = {}, 0 -- Table to hold our list of detected nameplates
  2. WorldFrame:HookScript('OnUpdate', function(self)
  3.     local currentWorldChildren = self:GetNumChildren()
  4.     if currentWorldChildren ~= PreviousWorldChildren then PreviousWorldChildren = currentWorldChildren
  5.         for _, plate in pairs({self:GetChildren()}) do
  6.             if not Nameplates[plate] then -- Check if it's already been seen
  7.                 local name = plate:GetName()
  8.                 if name and strmatch(name, '^NamePlate%d+$') then -- Test that it's a nameplate
  9.                     Nameplates[plate] = CreateFrame('frame', nil, WorldFrame) -- Record our new frame
  10.                     for i = 1, 500 do -- Make a bunch of regions for a stress test
  11.                         local fs = Nameplates[plate]:CreateFontString(nil, nil, 'GameFontNormalHuge')
  12.                         fs:SetText('LAG')
  13.                         fs:SetPoint('CENTER', math.random(-50,50), math.random(-12,12)) -- This is just to make it look more interesting
  14.                     end
  15.                 end
  16.             end
  17.         end
  18.     end
  19.     for plate, f in pairs(Nameplates) do -- Iterate over existing nameplates every frame
  20.         if plate:IsShown() then -- Check visibility
  21.             f:Hide() -- Try commenting this out and see what happens to your frame rate
  22.             f:SetSize(plate:GetSize()) -- This isn't necessary to call every update but it simplifies the example
  23.             f:SetPoint('CENTER', WorldFrame, 'BOTTOMLEFT', plate:GetCenter()) -- Position our frame relative to the nameplate
  24.             f:Show()
  25.         else -- Hide if nameplate is hidden
  26.             f:Hide()
  27.         end
  28.     end
  29. end)

You can forget about repositioning the frame OnUpdate without hiding it first, it doesn't seem to make as much of a difference as I thought. On the other hand, this trick seems to make a huge difference.

The only downside is it lags one frame behind the default nameplate, but maybe there's a way to overcome that.

There are 2000 font strings per nameplate in this screenshot, and while it has dropped my frame rate down to around 15 fps I can still smoothly rotate the camera and run around without any issues. Attaching them directly to the nameplate completely freezes the game in this same test.

Last edited by semlar : 08-21-13 at 06:17 AM.
  Reply With Quote