Notifications
Clear all

[Closed] Mini-Challenge #5. Are you ready?

that’s better.

2 Replies
 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

Actually, it should probably be done like this:

...
disableRefMsgs()
local sel = getCurrentSelection()
select objects
enableRefMsgs()
maxops.trackbar.redraw forceRedraw:on			
maxops.trackbar.unregisterfilter filtind		
disableRefMsgs()
select sel
enableRefMsgs()
...

to avoid situation in which the filter function raises an exception and max is left in an unstable state of no ref messages.

(@denist)
Joined: 11 months ago

Posts: 0

i’ve check you method on my machine:
Time: 225ms
Memory: 456L
Nodes Found: 753

so i stay with my method for a while

PS. lo,
to make the method complete you have to set previous CallbackFilterFunction back…

 lo1

Here is a variation that finds only nodes with animated materials. As Denis expected, the execution time goes up by about 1000% and memory by much more than that.

fn myCallbackFilterFunction theAnimatable theParent theSubAnimIndex theGrandParent theNode = 
	(
		if theParent != undefined and theNode.material != undefined and isController theAnimatable and
			theAnimatable.keys.count > 0 and findItem animatedNodes theNode == 0 and
			findItem (refs.dependents theAnimatable) theNode.material > 0 then
		(
			append animatedNodes theNode
			false
		)
		else true
	)
Time: 1172ms
Memory: 65720L
Nodes Found: 249

though to be practical, if this is the goal, it would probably be faster to traverse scene materials instead of nodes.

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

you can set #mat trackbar.filter to filter only material keys… it has to make everything faster

 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

Of course! So simple, thank you.

here is me with my method :


   fn isNodeAnimated node = 
   (
   	animated = off
   	object = node
   	if iskindof node SubAnim do
   	(
   		animated = (node.keys != undefined) and (node.keys.count > 0)
   		object = node.object
   	)
   	if iskindof object maxwrapper do for ca in object.custattributes while not animated do animated = isNodeAnimated ca
   	for k=1 to node.numsubs while not animated do animated = isNodeAnimated node[k]
   	animated
   )
   fn findAnimatedNodes nodes: = 
   (
   	if nodes == unsupplied do nodes = objects as array
   	for node in nodes where (isNodeAnimated node) collect node
   )
   fn findAnimatedMaterialNodes nodes: = 
   (
   	if nodes == unsupplied do nodes = objects as array
   	for node in nodes where node.mat != undefined and (isNodeAnimated node.mat) collect node
   )
   fn findAnimatedTransformNodes nodes: = 
   (
   	if nodes == unsupplied do nodes = objects as array
   	for node in nodes where (isNodeAnimated node.controller) collect node
   )
   

findAnimatedNodes
nodes:753
time:201 memory:264L

findAnimatedMaterialNodes
nodes:249
time:140 memory:264L

findAnimatedTransformNodes
nodes:183
time:85 memory:264L

it’s not bad, is it?

 lo1

Very nice! I would stay with your method too, if only for the sake of simplicity.

lo,
as i said, i wanted to try the method with callbackfilterfunction… technically it might be faster. we have to stop recursing the node after finding any animated track.

 lo1

Good idea. The difference is not noticable with 1000 nodes, but ~200% faster (~40% faster than your method) with 10000 nodes.

...
global approvedNode

	fn myCallbackFilterFunction theAnimatable theParent theSubAnimIndex theGrandParent theNode = 
	(
		if approvedNode == theNode then false else
		(
			if isController theAnimatable and theAnimatable.keys.count > 0 then
			(
				approvedNode = theNode
				append animatedNodes theNode			
				false
			)
			else true
		)
	)
...

technically we are not cutting the traversal of the node when we find it is animated, but we exit the function much faster for all subsequent animatables in the node.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

yep. sounds right. the reason to stay for me with my method is a simple way to make filters.
we found some way to make searching of animated materials for your method, but to find animated modifiers might be a problem.

there is another problem of the trackbar method… the trackbar might be hidden. in this case we have to set it to visible. it causes max and its viewport redraw. for heavy scenes it will be an issue.

 lo1

I guess it all depends on the context of the tool.

 lo1

what about:
movekeys all nodes 1 frames
controllerOtherEvent callback
moveKeys all nodes -1 frames

could work, but will probably be very slow.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

moveKeys is a controller function…
it tried deleteKeys and undo… it’s very slow, and fires event for all nodes

 lo1

I think the only way you’re ever going to get a faster solution is to write a c++ dlx version of your current method.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s not a problem but also not a point…

Page 4 / 5