Mini-Challenge #5. Are you ready?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Display Modes
  11 November 2011
Originally Posted by denisT: it seems like they broke something in recursive function method... it will be interesting to see the difference in 2010 and 2012... i can do it tomorrow... actually it's already today

ps. don't use [i] in code... it's reserved for italic font.

ok, will glad to see the difference (and why i not get 753 as well).
__________________
* everyone can win previous war
 
  11 November 2011
Originally Posted by Panayot: ok, will glad to see the difference (and why i not get 753 as well).

lo found them all
 
  11 November 2011
(
 	 local ts = timestamp()
 	 local mem = heapfree
 	 global animatedNodes = #()
 	 
 	 fn myCallbackFilterFunction theAnimatable theParent theSubAnimIndex theGrandParent theNode = 
 	 (	
 		 if isController theanimatable and theanimatable.keys.count>0 then
 		 (
 			 appendIfUnique animatedNodes theNode
 			 false
 		 )
 		 else true
 	 )
 	 
 	 with redraw off
 	 (	
 		 trackbar.filter = #all
 		 local filtind = maxops.trackbar.registerFilter myCallbackFilterFunction undefined "." 1 active:on
 		 select objects
 		 maxops.trackbar.redraw forceRedraw:on
 		 maxops.trackbar.unregisterfilter filtind
 		 clearSelection()
 		 format "Time: %ms\n" (timestamp()-ts)
 		 format "Memory: %\n" (mem-heapfree)
 		 format "Nodes Found: %\n" ((animatedNodes).count)
 		 ok
 	 )
  )
 
 

^ This is great, I never would of realized it could of been done this way.
I have a question though, about the line:
local filtind = maxops.trackbar.registerFilter myCallbackFilterFunction undefined "." 1 active:on

Does the fn myCallbackFilterFunction want 5 parameters? I see you are passing 3. I don't understand how that's working... Are you passing 'undefined' for 'theAnimatable' and then "." for theParent and then "1" for theSubAnimIndex? How do you pass theNode parameter? You guys write code that flies over my head sometimes.. even after digging into the maxscript help where the fn came from. Great challenge!
__________________


Last edited by TheGrak : 11 November 2011 at 10:16 AM.
 
  11 November 2011
I am never calling the filter function directly in the code. 3dsmax calls the function for every animatable in the scene, and supplies all 5 parameters.

http://docs.autodesk.com/3DSMAX/14/...6BA94E-2065.htm
 
  11 November 2011
Cheers for sharing Lo, very interesting method. I was way off
 
  11 November 2011
Sure, my pleasure.

Denis, I did not understand: is this the method you're using as well or do you have a different trick up your sleeve to be shown later?
 
  11 November 2011
Originally Posted by lo: I am never calling the filter function directly in the code. 3dsmax calls the function for every animatable in the scene, and supplies all 5 parameters.

http://docs.autodesk.com/3DSMAX/14/...6BA94E-2065.htm


lo,
i know that you see the shortcoming of your method. it's the selecting. the performance of the method depends on background callbacks. the method needs more tests... e.g. with opened material editor or trackview...
 
  11 November 2011
Originally Posted by lo: Sure, my pleasure.

Denis, I did not understand: is this the method you're using as well or do you have a different trick up your sleeve to be shown later?


no... it was my plan B for today... i use subanim recursive check. i will show it as soon as i get the max.
 
  11 November 2011
Originally Posted by denisT: lo found them all

Yep, awesome work!

My question still remain - why I get just 600 nodes?
Originally Posted by denisT: ps. don't use [i] in code... it's reserved for italic font

Well, my Explorer8 not show any forums formating issue with [i] inside [code] block,
but just in case, i attach my code as text file.
Attached Files
File Type: txt panayot_code.txt (642 Bytes, 0 views)
__________________
* everyone can win previous war
 
  11 November 2011
You're right. Callbacks should be taken into account. How about this:
fn longSelectionCallback =
(
	-- do something long and annoying
	sleep 1
)

-- add evil selection callbacks for testing
callbacks.addScript #selectionSetChanged "longSelectionCallback()" id:#testCB
global whenCB = when select objects[1] changes id:#testCB do longSelectionCallback()

(	
	local ts = timestamp()
	local mem = heapfree
	global animatedNodes = #()
	
	fn myCallbackFilterFunction theAnimatable theParent theSubAnimIndex theGrandParent theNode = 
	(		
		if isController theanimatable and theanimatable.keys.count>0 then
		(
			appendIfUnique animatedNodes theNode
			false
		)
		else true
	)
	
	with redraw off
	(	
		trackbar.filter = #all
		local filtind = maxops.trackbar.registerFilter myCallbackFilterFunction undefined "." 1 active:on
		disableRefMsgs()
		local sel = getCurrentSelection()
		select objects
		maxops.trackbar.redraw forceRedraw:on
		maxops.trackbar.unregisterfilter filtind		
		select sel
		enableRefMsgs()
		format "Time: %ms\n" (timestamp()-ts)
		format "Memory: %\n" (mem-heapfree)
		format "Nodes Found: %\n" ((animatedNodes).count)
		ok
	)
	
	callbacks.removeScripts id:#testCB
	deleteChangeHandler whenCB	
)


This way no callbacks get called. I checked it with trackview and material editor open, they made no difference.
 
  11 November 2011
Originally Posted by Panayot: My question still remain - why I get just 600 nodes?

for example you are not checking baseobject...
 
  11 November 2011
Originally Posted by lo: You're right. Callbacks should be taken into account. How about this:

... 	   disableRefMsgs()
 ... 	   enableRefMsgs()
 


This way no callbacks get called. I checked it with trackview and material editor open, they made no difference.


that's better.
 
  11 November 2011
Originally Posted by denisT: for example you are not checking baseobject...

aha, that make sense, thanks

meanwhile a funny idea hang round in my head,
but i have work to do right now.

pseudo code:
mapped fn getAnimated nodes &result = (
	selectKeys nodes
	if numSelKeys nodes > 0 do append result nodes
)
__________________
* everyone can win previous war
 
  11 November 2011
Originally Posted by denisT: that's better.


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.
 
  11 November 2011
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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:40 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.