[Closed] Simple Mod freeze / garbage collection error?
I am writing a simple mod plugin that uses values stored in point4tabs and stringtabs to control the deformation of the object. The modifier also has a function that calcultes the point offset based on the currentTime and the values stored in the arrays. One of the variables used is an array generated by executing a section of the stringtab. I have got everything working ok but when I apply the modifier I can only move the time slider a few frames before max will freeze, I used to get an error message stating that the was an error during garbage collection, or that maxscript has run out of memory. All of my variables are declared as local in the plugin definition, and I have also tried declaring them the map handler with no luck. Increasing the heapsize allows me to playback more frames but eventually max will freeze. Any suggestions on how to correct this problem would be great.
plugin simpleMod Animated_Damage
name:“Animated Damage”
classID:#(0x7fe0038f, 0x26cd88fc)
version:1
(
local simData
local simObj
local simI
local simP
local simVal
local simTemp
local t
local simOffset
local simDscale
local simDtime
local simDperiod
local simDexponent
fn simDamageDeform simP simData simObj simDscale simDtime simDperiod simDexponent =
(
simVal = [0,0,0]
for t = 1 to simData.count do
(
if currentTime.ticks >= simData[t][1][1] do
(
if currentTime.ticks <= simData[t][2][1] then
(
simVal = ((currentTime.ticks – simData[t][1][1]) / (simData[t][2][1] – simData[t][1][1]))
simVal *= simData[t][2][2] * ([simObj[2],simObj[3],simObj[4]] – simP)
simVal *= simDScale
)
else
(
simVal = cos ((90.0 * simDPeriod) * ((currentTime.ticks – simData[t][2][1]) / (simData[t][3][1] – simData[t][2][1])))
simVal *= simData[t][2][2] * ([simObj[2],simObj[3],simObj[4]] – simP)
simTemp = 1.0 – ((currentTime.ticks – simData[t][2][1]) / ((simData[t][3][1] – simData[t][2][1]) * simDTime))
if simTemp < 0 then simTemp = 0
simVal *= SimTemp ^ simDExponent
simVal *= SimDScale
)
)
)
return simVal
)
parameters main rollout:params
(
simDamData type:#stringTab tabSizeVariable:true
simDamObj type:#point4Tab tabSizeVariable:true
simDamTime type:#float ui:simTime default:1.0
simDamScale type:#float ui:simScale default:1.0
simDamExponent type:#float ui:simExponent default:1.0
simDamPeriod type:#float ui:simPeriod default:1.0
simDamAnimate type:#float ui:simAnimate default:0
)
rollout params “Animated Damage”
(
spinner simTime “Time Scale: ” range:[.0001,1000,1] type:#float fieldWidth:40
spinner simScale “Rebound Scale: ” range:[.0001,1000,1] type:#float fieldWidth:40
spinner simExponent “Exponent: ” range:[.0001,1000,1] type:#float fieldWidth:40
spinner simPeriod “Period: ” range:[.0001,1000,1] type:#float fieldWidth:40
spinner simAnimate “Animate: ” range:[0,1,0] type:#float fieldWidth:40
)
on map simI simP do
(
simDscale = simDamScale
simDtime = simDamtime
simDperiod = simDamPeriod
simDexponent = simDamExponent
if simI != 0 then
(
try(
simObj = simDamObj[simI]
simData = execute simDamData[simObj[1]]
simOffset = simDamageDeform simP simData simObj simDscale simDtime simDperiod simDexponent
simP += simOffset
)catch()
)
else
(
–gc lite
)
simP
)
)
-bnvm