Thread Tools Display Modes
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,740
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.
| WoWI AddOns | GitHub | Zork (WoW)

"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.
  Reply With Quote
08-21-13, 07:14 PM   #22
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Plenty of insight here explains why my nameplates have sucked so much on the ptr lately.
__________________
Tweets YouTube Website
  Reply With Quote
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
  Reply With Quote
08-22-13, 08:12 AM   #24
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
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)
__________________
Tweets YouTube Website
  Reply With Quote
10-05-14, 06:17 AM   #25
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
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.
  Reply With Quote
10-05-14, 07:14 AM   #26
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Looking good.
  Reply With Quote
10-05-14, 08:02 AM   #27
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Nice one! I'll borrow this, thank alot
  Reply With Quote
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,740
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.
| WoWI AddOns | GitHub | Zork (WoW)

"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.
  Reply With Quote
10-06-14, 07:30 AM   #29
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
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.
  Reply With Quote
10-06-14, 09:52 AM   #30
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
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?
  Reply With Quote
10-06-14, 04:49 PM   #31
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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!
  Reply With Quote
11-03-14, 09:35 AM   #32
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Just to post it here.

Since 6.0.2 the new rNamePlates is using the sizer technique semlar described.

rNamePlates: https://code.google.com/p/rothui/sou...tes.lua?r=1311

With WoD going live in a few days a new aura module will be available. So if you need to do sth like that you can check the diff.



Aura Module diff: https://code.google.com/p/rothui/sou...s.lua&old=1311

Current version: https://code.google.com/p/rothui/sou...NamePlates.lua

Btw I would have loved calling the ScanAuras() function for mouseover units when NamePlate OnEnter is triggered. But as soon as I set NamePlate:EnableMouse(true) and anchor the OnEnter handler the click function on nameplates is broken.

Anyone has a clue why? I mean the tooltip pops up if I have a nameplate. Wierd.

Without EnableMouse the OnEnter handler does not fire. Grmpf.

*edit* Updated rNamePlates to 60000.03. http://www.wowinterface.com/download...tesDiablo.html
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

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

Last edited by zork : 11-04-14 at 04:02 AM.
  Reply With Quote
07-24-16, 05:16 PM   #33
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
My old script that hid your frame before repositioning it is no longer necessary, and will in fact probably result in worse performance since textures are unloaded from memory when they're hidden and have to be read from the disk again when they're shown.

You can now safely parent and anchor to the base nameplate frame without much issue.

However, I ran into major performance problems from nameplates scaling based on distance, and have hard-coded their min and max scale to the same number to prevent it from happening.
Lua Code:
  1. SetCVar('namePlateMinScale', 1)
  2. SetCVar('namePlateMaxScale', 1)
  Reply With Quote
07-25-16, 01:49 AM   #34
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by semlar View Post
However, I ran into major performance problems from nameplates scaling based on distance, and have hard-coded their min and max scale to the same number to prevent it from happening.
Lua Code:
  1. SetCVar('namePlateMinScale', 1)
  2. SetCVar('namePlateMaxScale', 1)
This also fixes my FPS drops when using OUTLINE. <3
  Reply With Quote

WoWInterface » 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