Reply
Thread Tools Display Modes
Unread 08-21-13, 02:03 PM   #21
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,367
Not sure semlar, sorry.

I'm nearly finished with my new nameplate addon.

Here is what I got so far:


*edit*

Tests are finished. rNamePlates2 is released.

http://www.wowinterface.com/download...mePlates2.html
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 08-21-13 at 06:01 PM.
zork is offline   Reply With Quote
Unread 08-21-13, 07:14 PM   #22
10leej
A Scalebane Royal Guard
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 440
Plenty of insight here explains why my nameplates have sucked so much on the ptr lately.
10leej is offline   Reply With Quote
Unread 08-21-13, 08:31 PM   #23
olaya
A Kobold Labourer
Join Date: Aug 2013
Posts: 1
Thumbs up

Originally Posted by 10leej View Post
Plenty of insight here explains why my nameplates have sucked so much on the ptr lately.
la mison quiero jugar y una battalal para poder comecnsar el juego
olaya is offline   Reply With Quote
Unread 08-22-13, 08:12 AM   #24
10leej
A Scalebane Royal Guard
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 440
Originally Posted by olaya View Post
la mison quiero jugar y una battalal para poder comecnsar el juego
Mi español es bastante terrible que creo que estás hablando acerca de cómo iniciar un juego?


(Estoy usando traductor Google)
10leej is offline   Reply With Quote
Unread 10-05-14, 06:17 AM   #25
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 601
I've come up with a new design which solves the one major drawback my previous method had, which was the 1 frame delay between updates so our nameplate would lag behind the real one.
Lua Code:
  1. local Nameplates, PreviousWorldChildren = {}, 0
  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
  7.                 local name = plate:GetName()
  8.                 if name and strmatch(name, '^NamePlate%d+$') then
  9.                     local f = CreateFrame('frame', nil, WorldFrame)
  10.                     Nameplates[plate] = f
  11.                     f:SetSize(1, 1)
  12.                    
  13.                     for i = 1, 500 do -- Make a bunch of regions for a stress test
  14.                         local fs = f:CreateFontString(nil, nil, 'GameFontNormalHuge')
  15.                         fs:SetText('LAG')
  16.                         fs:SetPoint('CENTER', f, math.random(-50,50), math.random(-12,12))
  17.                     end
  18.                    
  19.                     -- Attach a frame to the nameplate which will fire OnSizeChanged when it moves
  20.                     local sizer = CreateFrame('frame', nil, f)
  21.                     sizer:SetPoint('BOTTOMLEFT', WorldFrame)
  22.                     sizer:SetPoint('TOPRIGHT', plate, 'CENTER')
  23.                     sizer:SetScript('OnSizeChanged', function(self, x, y)
  24.                         f:Hide() -- Important, never move the frame while it's visible
  25.                         f:SetPoint('CENTER', WorldFrame, 'BOTTOMLEFT', x, y) -- Immediately reposition frame
  26.                         f:Show()
  27.                     end)
  28.                    
  29.                     plate:HookScript('OnHide', function() f:Hide() end)
  30.                     plate:HookScript('OnShow', function() f:Show() end)
  31.                 end
  32.             end
  33.         end
  34.     end
  35. end)

This works by creating an extra frame for every nameplate which is attached to the edge of the screen and the center of the nameplate, so that any time the nameplate moves it calls the OnSizeChanged script which is where we reposition our custom nameplate.

Other than that it's the same as it was before, but now it only updates if the frame has actually moved, and it should stay above the unit's head as the camera moves, rather than lag behind.
semlar is offline   Reply With Quote
Unread 10-05-14, 07:14 AM   #26
Resike
A Molten Giant
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 618
Looking good.
Resike is offline   Reply With Quote
Unread 10-05-14, 08:02 AM   #27
sticklord
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 21
Nice one! I'll borrow this, thank alot
sticklord is offline   Reply With Quote
Unread 10-06-14, 03:47 AM   #28
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,367
Genius idea. I love that.

I would add one exception to the setpoint function though. A function that checks if the plate is shown before you apply the new setpoint. Because otherwise you might show a plate that is not visible.

Btw there is another thing that I read about. NamePlates change index on every /reloadui. But one could check the worldframe children on every OnUpdate until the first one pops up.

After that one just checks for nameplates per index instead of parsing the children all the time.

Here is the adapted code:
Lua Code:
  1. local newPlates, namePlateIndex, _G, string = {}, nil, _G, string
  2.  
  3. WorldFrame:HookScript('OnUpdate', function(self)
  4.   if not namePlateIndex then
  5.     for _, blizzPlate in pairs({self:GetChildren()}) do
  6.       local name = blizzPlate:GetName()
  7.       if name and string.match(name, '^NamePlate%d+$') then
  8.         namePlateIndex = string.gsub(name,'NamePlate','')
  9.         break
  10.       end
  11.     end
  12.   else
  13.     local blizzPlate = _G["NamePlate"..namePlateIndex]
  14.     if not blizzPlate then return end
  15.     if not newPlates[blizzPlate] then
  16.       local newPlate = CreateFrame('Frame', nil, WorldFrame)
  17.       newPlates[blizzPlate] = newPlate
  18.       print(namePlateIndex)
  19.       namePlateIndex = namePlateIndex+1
  20.       newPlate:SetSize(1, 1)      
  21.       for i = 1, 500 do -- Make a bunch of regions for a stress test
  22.         local fs = newPlate:CreateFontString(nil, nil, 'GameFontNormalHuge')
  23.         fs:SetText(namePlateIndex)
  24.         fs:SetPoint('CENTER', newPlate, math.random(-50,50), math.random(-12,12))
  25.       end      
  26.       -- Attach a frame to the nameblizzPlate which will fire OnSizeChanged when it moves
  27.       local sizer = CreateFrame('Frame', nil, newPlate)
  28.       sizer:SetPoint('BOTTOMLEFT', WorldFrame)
  29.       sizer:SetPoint('TOPRIGHT', blizzPlate, 'CENTER')
  30.       sizer:SetScript('OnSizeChanged', function(self, x, y)
  31.         if blizzPlate:IsShown() then
  32.           newPlate:Hide() -- Important, never move the frame while it's visible
  33.           newPlate:SetPoint('CENTER', WorldFrame, 'BOTTOMLEFT', x, y) -- Immediately reposition frame
  34.           newPlate:Show()
  35.         end
  36.       end)    
  37.       blizzPlate:HookScript('OnHide', function() newPlate:Hide() end)
  38.       blizzPlate:HookScript('OnShow', function() newPlate:Show() end)
  39.     end
  40.   end  
  41. end)
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-06-14 at 04:56 AM.
zork is offline   Reply With Quote
Unread 10-06-14, 07:30 AM   #29
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 601
Originally Posted by zork View Post
I would add one exception to the setpoint function though. A function that checks if the plate is shown before you apply the new setpoint. Because otherwise you might show a plate that is not visible.
I originally double checked that the plate was shown, but OnSizeChanged won't fire while the frame is hidden and we're hiding the sizer frame when the plate is hidden, so it shouldn't ever become a problem.

As for scanning for new plates, I'm not suggesting that this is the best way to do it, I just wanted a compact example to demonstrate the positioning method.

If you use the index approach, you may not want to break out of the loop after the first nameplate is found if the code has the potential to ever be run after more than one nameplate has already been created.
semlar is offline   Reply With Quote
Unread 10-06-14, 09:52 AM   #30
myrroddin
Premium Member
 
myrroddin's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 384
I haven't really looked at the new 6.0 APIs closely, so I expect this to be debunked fast, but: what about exchanging the OnUpdate script for the new C.Timer (whatever it is called) thing? Being C-side, if it works, wouldn't it be much faster?
myrroddin is offline   Reply With Quote
Unread 10-06-14, 04:49 PM   #31
Lombra
A Cobalt Mageweaver
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 236
The actual callback function will take just as long to execute whether it's C_Timer or OnUpdate. I'm not too involved in nameplates, but I think that OnUpdate is exactly how often you need to do your stuff (eg before each frame is drawn), so there's no point in using a timer, and it would probably even be slightly worse, because you could never time it exactly according to each frame.
__________________
Grab your sword and fight the Horde!
Lombra is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » General Authoring Discussion » Nameplate FPS drop research

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off