i have a script request! (Poses)

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
synthsin75
Posts: 9972
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

What?! A new scripter? :shock: Heaven be praised, we are saved!! :wink:
User avatar
Víctor Paredes
Site Admin
Posts: 5660
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Updated Script - no memory leaks

Post by Víctor Paredes »

_Trip wrote:Anyway, I did modify the script a bit to fix the memory leak that was occuring and changed a couple of the "for" loops to ensure the fastest possible interpretation. I think what I've added could be used in most all of the scripts I've seen to help with those niggling and intemittent memory leaks/speed issues.
It sounds great, and thanks, i'm very happy to see a new wise member , but I could not make your code work.
I don't know if i'm doing something wrong or what.

Have somebody tried it successfully?

thanks.
User avatar
synthsin75
Posts: 9972
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Mmm, just tried it, and it doesn't work. I compared it to Genete's, and it looks a bit odd. But I'm no scripter, so I only vaguely know what I'm looking at.

_Trip, if you could provide a working example file, that would be awesome.
_Trip
Posts: 5
Joined: Thu Jun 05, 2008 3:37 pm
Location: WI
Contact:

??!

Post by _Trip »

Hmmm - just tried copying/pasting the script from what I posted and all worked well for me..

I'm no Lua scripting guru, but the changes I made should definately not look odd... I simply removed the calculation from happening on each "for" iteration" and added a garbagecollection function call twice.

What errors are you getting?

I am running the 5.6 version off AS that I just purchased about a week and a half ago. Am also running WIndows 2008 Server on my laptop.

When I run the test animation, no memory leak occurs while I move the bone all over the place...

Copy the demo that was uploaded from a previous post and past the script into the one... Maybe a "New" one doesn't work? (Haven't tried that...)

-Tim
-Tim
User avatar
Víctor Paredes
Site Admin
Posts: 5660
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: ??!

Post by Víctor Paredes »

_Trip wrote:Copy the demo that was uploaded from a previous post and past the script into the one... Maybe a "New" one doesn't work? (Haven't tried that...)
:shock: that works. thanks!. I have tried with a very complex character, and it works slow, but never stop to work (but i suppose that is because my character is really really complex). I'll try with some other simpler and I'll wrote how it's going.

here is the file, if you want to see.

thanks again.
User avatar
synthsin75
Posts: 9972
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Oh, sorry. I didn't realize that it didn't work on frames that are being used as pose reference. Seems to work well. Thanks Trip.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Good lord! Be still my beating heart...

... do we have another possible lua scripter on the forum???

;)

-vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Holy cow! It does work much better! I can whip that bone across the screen really fast without any trouble! Sure it doesn't update immediately but it freaking works! Woohoo!

I'm excited again. I plan to dissect that script if you don't mind _Trip. I want to see if that "looping reduction/garbage collection" can be implemented in any of other scripts.

-vern
User avatar
synthsin75
Posts: 9972
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Vern, any hope of these performance enhancements helping Genete's auto-shape-sort script?
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

synthsin75 wrote:Vern, any hope of these performance enhancements helping Genete's auto-shape-sort script?
I am not sure yet. I haven't even really looked at the code at all yet. I have to see what is going on... but... I wouldn't doubt it. 90% of most of these scripts involve TONS AND TONS AND TONS OF LOOPING. Anything that can streamline that... is going to help in some way I would hope.

-vern
DarthFurby
Posts: 510
Joined: Sat Jul 29, 2006 1:34 pm
Location: New York City
Contact:

Post by DarthFurby »

_Trip thank you so much for fixing the lag!! The script works great now! Your code may have opened the door for a lot of other scripts too it seems. As you've probably noticed, when a potentially new lua scripter appears it's a big deal. Like water in the desert. Thanks again.

selgin, that Pinochet character looks amazing! Love the artwork and design, and the way you have the pose bones set up makes me think of animatronics or puppeteering. Very cool!

Genete, the pose bone works for point motion, but would it be possible to add the other channels? Like fill color, scale, bone angle, layer rotation, camera zoom, etc? There are at least 20 more channels. This is a monumental task, so I would understand if you didn't have time, but I think this script could be very important for 2d animation production, and it could make you famous.

Here's a new working sideturn pose model with _Trip's script:

http://darthfurby.com/as/posemodel_trip.zip
_Trip
Posts: 5
Joined: Thu Jun 05, 2008 3:37 pm
Location: WI
Contact:

Post by _Trip »

Thanks all! Glad to be of help. Have no idea how to script for AS, but my forte is in code review/c# and performance tuning and certain things tend to work well in all languages. ;)

It will be awhile before I could script something "new"; however, send me scripts to test and I can usually find the bottlenecks. :)

heyvern - it was a surprise to see you here - I've been a member of A:M forums for years (don't post much there either though.. :( ) ... Always a pleasure!

Look forward to helping where I can!

-Tim

p.s. LOVE everyone's work that I've seen thus far.
-Tim
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Hey! Small world! There seems to be a lot of "cross over" with A:M and AS forum members. There's a few more of us here. Funny world.

The kind of scripting help you offer is often better than creating new scripts (and easier for you. ;) ). I am not a very good programmer. I can get it done... and it works... but... ick. It's those looping bottlenecks that make my head spin. After struggling for hours on some complex looping code structure... if the darn thing works I just cry with joy and move along. ;)

p.s. Martin asked me real nicely to come back to the A:M forum recently so I've been hanging out there a bit to show my support. So nice to be wanted. I get a little teary eyed. ;)

-vern
User avatar
synthsin75
Posts: 9972
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Hey _Trip, if you get a chance, could you check out this auto-sort script for performance issues?
http://darthfurby.com/genete/Scripting/ ... ls_v10.zip


It's the sort_shapes9.1.lua, but definitely feel free to check out the rest. This one is only one I have performance trouble with.

viewtopic.php?p=58956#58956
You can check out what I'm doing with this script here. The performance is keeping me from extending this technique to an entire character.

Just if you get a chance. Don't want to run a scripter of any skill off, and like Vern said performance tuning existing scripts would be a god send. :wink:
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Hey guys!
you're so excited!! But there are some things I don't understand.

First of all I wish say hello and welcome to _Trip. I hope you get hooked with AS and all its possibilities and contribute with your programming and animation skills to this forum.

Analysing the modifications that you have made to the script I don't fully understand some things:

You've added an additional variable to the followings values:

Code: Select all

      for k=1, maxposes do
         bone[k] = nil
         local fc1 = skel:CountBones()-1   -- added to speed up loops
         for i=0, fc1 do


in the for - end that look up for the bones.

Other similar here:

Code: Select all

      local fc2 = mesh:CountPoints()-1   -- added to speed up loops
      for k=1, maxposes do
         poses[layer]["points"][k]={}
         for i=0, fc2 do
and other similar here:

Code: Select all

    local fc3=mesh:CountPoints()-1  -- added to speed up loops
   for i=0, fc3 do --- move the points.
The only one that really do something useful is the second one (because it is calculated outside another 'for' loop). The other two are useless and can be avoided with no effect. They are just calculated before the loop so no performance gain is obtained.

Regarding to the collectgarbage() function call you do I don't know if it would help or not to the script. In one hand it is a function call (that I don't know how much time would it spend in return) and in the other hand is the memory handling (the lua documentation says you should call it with some argument:

http://www.lua.org/manual/5.1/manual.ht ... ectgarbage

So I really don't know if it would help or not.

To really increase the performance of this script the things to do are:

Make the bone search in other script (call it only one time).
Make the point pose array store in other script (you don't need to collect them all every time the Layer script is called.
Make the weights calculations the same as the point poses.
Let the Layer script do only the points movements based on all those values stored externally.

The problem:
By the way that Moho is constructed you cannot be completely sure that the arrays are kept. I've tried this before (and heyvern knows it very well) and it fails.

Anyway I can try it again. Just have to rewrite the script in external ones and store the values in some recurring values variables.

Darth, it is possible to do the same for the channels that allow the same trick that the point animation. But not for all the channels that are animatable. There is not script interface for some of them.

synthsin75, it is possible to do it a little faster using some intermediate variables but I don't think there is so much room for improvement there beyond the external store of the static values as I have commented to the other script.

Don't be sad with my words. I don't promise anything but the thing is moving again..... and the summer is here. Patience please. My free time is limited :)

:D
-G
Post Reply