I've got a fairly basic script (I can throw it here on demand) - I gather all of the materials in the scene with a specific prefix, confirm their sub-maps are of a specific type (via classof) - and then edit simple flags (visible, etc) - for them.
I added timestamping, and the code itself runs _fast_ - we're only talking a dozen or so simple materials. However right before it ends, it takes 30+ seconds to clear the final function. If I do _all_ of the code _except_ editing a map (I just comment out only the X=Y code) - it runs super fast, exits right away.
Does this raise a flag with anyone? Is there some specific dumb thing I may need to look for? I feel like the fact that the delay is only when an object is changed, that it's related to instancing or some sort of dirty-data cache... but the scene in terms of materials is not that complex - and 30 seconds is a _ton_ of time for a modern machine to do work...
Any and all thoughts would be appreciated...
fn matGather &mat &mats =
(
if ((findstring mat.name "MAT[") == 1) then
(
appendIfUnique mats mat
)
mats
)
fn matGatherMul &mat &mats =
(
for m in mat.materialList do
(
if (classof m == Standardmaterial) then
(
matGather &m &mats
)
)
)
fn matGatherScene &mats =
(
for m in sceneMaterials do
(
if (classof m == Multimaterial) then
(
matGatherMul &m &mats
)
if (classof m == Standardmaterial) then
(
matGather &m &mats
)
)
)
fn diffGetMap diff =
(
if (classof diff == Bitmaptexture) then
(
diff
)
else
(
if (classof diff == CompositeTexturemap) then
(
diffGetMap diff.mapList[1]
) else (
undefined
)
)
)
fn colorApply &cc apply =
(
cc.lightnessMode = 1
cc.enableR = true
cc.gainR = (apply.r/255)*100
cc.enableG = true
cc.gainG = (apply.g/255)*100
cc.enableB = true
cc.gainB = (apply.b/255)*100
)
fn teamCreate &diffM teamC stripeC =
(
wantTeam = substitutestring diffM.filename "_DIFF." "_TEAM."
wantStripe = substitutestring diffM.filename "_DIFF." "_STRP."
teamM = undefined
stripeM = undefined
valid = 1
try ( teamM = BitmapTexture filename:wantTeam ) catch ( valid = 0 )
try ( stripeM = BitmapTexture filename:wantStripe ) catch ( valid = 0 )
if (valid == 1) then
(
holdC = CompositeTexturemap()
holdC.mapEnabled.count = 3
teamCor = ColorCorrection()
colorApply teamCor teamC
teamCor.map = teamM
stripeCor = ColorCorrection()
colorApply stripeCor stripeC
stripeCor.map = stripeM
holdC.mapList = #(diffM, teamCor, stripeCor)
holdC.layerName = #("diff", "team", "stripe")
holdC
) else (
diffM
)
)
fn teamShow &mat show teamC stripeC =
(
diffC = mat.diffuseMap
diffM = diffGetMap diffC
if (diffM != undefined) then
(
if (classof diffC == BitmapTexture) then
(
diffC = teamCreate diffC teamC stripeC
mat.diffuseMap = diffC
)
)
if (classof diffC == CompositeTexturemap) then
(
if (diffC.mapList.count == 3) then
(
if (diffC.layerName[2] == "team") then
(
if (diffC.layerName[3] == "stripe") then
(
diffC.mapEnabled[2] = show
diffC.mapEnabled[3] = show
if (classof diffC.mapList[2] == ColorCorrection) then ( colorApply diffC.mapList[2] teamC )
if (classof diffC.mapList[3] == ColorCorrection) then ( colorApply diffC.mapList[3] stripeC )
)
)
)
)
)
fn visualizeTeams show teamC stripeC =
(
matSet = #()
matGatherScene matSet
for m in matSet do
(
teamShow m show teamC stripeC
)
-- DELAYS RIGHT HERE FOR AGES!!!
matSet = #()
)
barigazy · 2013-12-24