[Closed] The Challenge >>> Biped Figure Mode
fn getbodycontrollers = (for obj in geometry where iskindof (c = obj.controller) Vertical_Horizontal_Turn collect c)
(
t0 = timestamp()
h0 = heapfree
for k=1 to 1 do
(
--getclassinstances Vertical_Horizontal_Turn processAllAnimatables:on
getbodycontrollers()
)
format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)
for 1000 biped default skeletons:
getclassinstances >> time:121 heap:192L
getbodycontrollers >> time:64 heap:192L
i just know the code behind getclassinstances … it cann’t be fast with that algorithm. I have my own mxs extension method that searches only TM controllers. it gives me:
getbodycontrols >> time:7 heap:192L
Well, the numbers here are quite the contrary, might be due to my quantum processor.
getclassinstances >> time:72 heap:171448L
getbodycontrollers >> time:264 heap:10725664L
Oh! Why are these ‘heap’ numbers on your machine? It should not leak at all! All memory usage is about creating one mxs array…
BTW, what MAX vertion is it?
Ha! I thought it was something new, but it’s very old. My “target” version is now 2016
Max 2014
getclassinstances >> time:72 heap:171448L
getbodycontrollers >> time:264 heap:10725664L
Max 2016
getclassinstances >> time:59 heap:149264L
getbodycontrollers >> time:213 heap:8934544L
Max 2021
getclassinstances >> time:60 heap:156324L
getbodycontrollers >> time:303 heap:10168484L
PolyTools3D:
might be due to my quantum processor.
You are excluded from the list of testers!
In fact, this is what I ended up with after a series of experiments – monitor the scene with a NodeEventCallback and catch changes (notifications) of a reference target(s) (in our case this is the Body controller) with ‘when construct’ for isolated targets.
Now the next step… Can we make some sort of universal ‘monitor’ for this kind of tasks?
I guess that, with a “clear goal” and a bit of patience, it could be done, at least for some properties/classes.
Here is a little attempt that needs A LOT more work to be used in production:
try(destroyDialog ::RO_PROPERTY_MONITOR) catch()
rollout RO_PROPERTY_MONITOR "Property Monitor" width:222 height:100
(
edittext ed_class "Class:" pos:[ 25, 8] fieldwidth:156 text:"Vertical_Horizontal_Turn"
edittext ed_property "Property:" pos:[ 8,32] fieldwidth:156 text:"figureMode"
checkbutton chk_state "STATE" pos:[ 8,60] width:48 height:32 enabled:false
checkbutton chk_monitor "Enable Monitor" pos:[ 58,60] width:156 height:32
local instances = #()
local nodesCallback = undefined
local theClass = undefined
local theProperty = undefined
fn UpdateUI =
(
state = false
for ctrl in instances do state = state or (getProperty ctrl theProperty)
chk_state.state = state
)
fn UpdateInstances event node =
(
deleteAllChangeHandlers id:#ID_0X712292CE
instances = getClassInstances theClass
when parameters instances changes id:#ID_0X712292CE handleAt:#redrawViews do UpdateUI()
UpdateUI()
)
fn EnableMonitor state:false =
(
theClass = execute ed_class.text -- Needs to be validated (NOT IMPLEMENTED)
theProperty = ed_property.text -- Needs to be validated (NOT IMPLEMENTED) (only boolean in this example)
ed_class.enabled = ed_property.enabled = not state
if state then
(
UpdateInstances 0 0
nodesCallback = NodeEventCallback added:UpdateInstances deleted:UpdateInstances
)else(
deleteAllChangeHandlers id:#ID_0X712292CE
nodesCallback = undefined
gc light:on
)
)
on chk_monitor changed arg do EnableMonitor state:arg
on RO_PROPERTY_MONITOR close do EnableMonitor state:false
)
createDialog ::RO_PROPERTY_MONITOR
Forget about being a little faster … let’s assume getclassinstances works well enough
Recent Topics
-
Need help with script to automate certain things
By siddhartha 3 weeks ago
-
By Dave 4 months ago
-
By MZ1 1 year ago
-
By brianstorm 1 year ago
-
By MZ1 1 year ago
-
Support class with multiple name (C#,SDK)
By MZ1 1 year ago
-
How to sort subarrays for Mat ID swapping
By brianstorm 1 year ago