Hi ! I'm trying to make a script that displays the drawcalls count of a selection.
It only works on editable poly for now. I'm looping through the mesh to get all mat id.
global winWidth = (gw.getWinSizeX() / 2 - 20)
global drawcalls = "Drawcalls: "
fn GW_displayDrawCalls evt nodes=
(
fn getDrawCalls dc_selObj =
(
global_dc = 0
for i = 1 to dc_selObj.count do
(
dc_obj =dc_selObj[i]
if classof dc_obj == editable_poly do
(
if classof dc_obj.material == multimaterial do
(
dc_idCount = 0
for i=1 to dc_obj.material.numSubs do
(
dc_obj.selectByMaterial i
dc_faces = polyop.getFaceSelection dc_obj
if dc_faces.numberset != 0 do (dc_idCount+=1)
)
global_dc += dc_idCount
)
if classof dc_obj.material != multimaterial do
(
global_dc+=1
)
)
)
gw.updatescreen()
return "Drawcalls: "+ (global_dc as string) + " "
)
drawcalls = ((getDrawCalls selection) as string )
)
callbackItem = undefined;
gc()
callbackItem = NodeEventCallback selectionChanged:GW_displayDrawCalls
unregisterRedrawViewsCallback displayDrawCalls
fn displayDrawCalls =
(
gw.wtext [winWidth, 19, 20] (drawcalls) color: [229,204,25]
)
registerRedrawViewsCallback displayDrawCalls
The issue is my scene is slow when i select an object (complex object in a complex scene), eventhough i use a NodeEventCallback selectionChanged. It looks like the code is executed all the time instead of on selection change ?
Thanks for insight.
Replies