01 January 2009 | |
![]() |
|
Jack of All Trades
Kevin Mackey
Arlington Hts,
USA
|
Limiting updates for script controllers?
I've been messing around with script controllers, and have found that they tend to update a bit more often than is actually necessary. I'm concerned that a scene with a lot of them could end up getting really sluggish. Take the following as an example of what I mean about unneccesary updating:
This only needs to be updated when the x position of the box is changed, but you can see from the output to the listener that the script is called any time a change is made to the position or rotation of the box (selecting scale crashes Max, at least for me). Is there a way to set the script controller to update only on a change in the x position? Maybe even just some way to check if the value has changed, and if it hasn't to skip the rest of the script? |
01 January 2009 | |
![]() |
|
Frequenter
portfolio
Rob Galanakis
Technical Animator
Bioware Austin
Austin,
USA
|
Couldn't you store a constant on the script controller, and put the code inside an if statement that only executes when the stored constant value is different from the value you are checking. So:
if someStoredConstant != thebox.pos.x then ( someStoredConstant = box.pos.x doSomething() ) |
01 January 2009 | |
![]() |
|
Jack of All Trades
Kevin Mackey
Arlington Hts,
USA
|
I managed to get something that does what I want. I don't know if it is the most efficient way to do it, but it could save time for more complex script controllers.
I couldn't figure out a way to define a variable from within the controller that would save a value (I guess it would have to be outside the scope of the controller), so I'm currently using the helper as a workaround. If anyone can show me a better way to do this, I would be very appreciative!
---- OLD: Sorry, a constant wouldn't work for what I need. I do want the script to be called any time the X position is changed, not only when it is different from a particular set value. Last edited by Malkalypse : 01 January 2009 at 06:33 PM. |
01 January 2009 | |
![]() |
|
Frequenter
portfolio
Rob Galanakis
Technical Animator
Bioware Austin
Austin,
USA
|
Will repost/edit when I have sample code.
Last edited by RobGalanakis : 01 January 2009 at 06:44 PM. |
01 January 2009 | |
![]() |
|
Frequenter
Sami Sorjonen
Finland
|
Hi Kevin!
I've had problems with something similar. Test this; Unckeck "Time Configuration" / "realtime" and ALSO "Loop" and then set your time timeline to say 0-10 frames. Go to beginning of timeline, clear listener, press play. You should see 10 print outs of format by your script... Put "Realtime" back on, and press play. You'll get twice or triple the amount of formats.... So i don't have answer for this, only have noticed this. Maybe script controller tries to update as often as it can or something. Same goes for transformations. Rotation will trigger update as much as move. I haven't found anything in docs, but then again, haven't had time to dig into this. For storing data, you could try storing values to a variable inside custom attribute:
I hope this helps a bit! Seems like there is no easy way to control how many times script controller will update for a frame, but maybe i'm wrong! __________________
- S-S Last edited by S-S : 01 January 2009 at 12:01 PM. |
01 January 2009 | |
![]() |
|
ruɾamöχ
portfolio
Ruramuq
|
I think max is not implemented that way, it should, if script controller would allow the creation of keys, that would be a mess. but your script controller is going to be evaluated anyways, even if you think it is not
@S-S when realtime is active, and max is playing.. max uses ticks, so it is indeed evaluating more times I suppose to make it fluid when realtime is off it only uses frames. when the timeslider is dragged it always uses frames some notes..: controllers depends on the matrix itself, so scale and rotation are tied anyway, but : when a frame is evaluated position is evaluated first then rotation then scale POS ROT SCALE controllers (always in that order) but subanims X Y Z themselves are evaluated always no matter tha axis you move(tied) when the max scale tool is active, the object selected, and scale controller has no subanims, the transform gizmo is visible and the mouse is over it: the scale controller is evaluated (it should not, a bug?) if a controller has subanims (ie: POS X Y Z) max does evaluate those but not the subanims of other controllers (ie: ROT XYZ or SCALE XYZ) subanims behabes like max hierarchies, "Linked". In a Hierarchy, max gives priority to the parent, and childs tend to jump evaluations, it may happen something similar with controllers __________________
may not be following this thread. . |
01 January 2009 | |
![]() |
|
Expert
|
Thread automatically closed
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. |
Thread Closed share thread |
«
Previous Thread
|
Next Thread
»
|
|
|