Re: Display Callback Performance

Date : Fri, 03 Mar 2006 15:20:36 -0800
To : XSI(at)Softimage.COM
From : Andy Jones <andy(at)thefront.com>
Subject : Re: Display Callback Performance
Does anyone know of a convenient way to look up the direct numerical index of a given parameter name once, so that the name-based lookup can be performed once, then the numerical index can be used from then on?

Obviously, you could look the parameter up by name and then check each index-based lookup in a loop to see if it matches, but surely there's a nicer way. Basically, like a getIndexOf() method is what I'm after.

-Andy

Guy Rabiller wrote:

Hi Hans,

regarding the MyProperty.GetParameterValue() part, you should try to use array indices on parameters ref array.

CParameterRefArray oParams( MyProperty.GetParameters() );

Then get the values directly:

CValue oVal1( Parameter(oParams[0]).GetValue() );

Of course you should seek for the right parameter index, but on known Properties, it should be persistent.
( That said, you'll need to re-check this after a new XSI version is released ).


You should see significant speed boost.
( I got ~30% speed increase on our fluids simulation plugins with this ).

Also, avoid Find at all cost. Better use a GetProperties().GetItem( L"MyProp" ) then check if the CRef is of ClassID siPropertyID ( or siCustomPropertyID ).

For finding objects you might try the CLSID path rather than the FindChildren one, albeit I didnt run extensive tests on this one.
( using the FindObjects Command with the CLSID of the Null Class - for instance - wich is {5FC0CCAE-3DC8-11D0-9449-00AA006D3165} ).


Let me know.

--
guy rabiller | 3d technical director (at) LaMaison


Hans,Veenendaal,AMplus R&D,SOJ a écrit :

Hello All,
I've created a Display Callback that adds visualization for a Custom Property connected to nulls.
When I create several of those nulls the performance really drops, while I'm not drawing anything heavy.
Statistics: 37 Nulls (Hidden)
No Display Callback: 60.0 Hz. [Nothing is Drawn except for standard view]
With Display Callback: 7.8 Hz. [Nothing is Drawn except for standard view]
Statistics: 37 Nulls (Visible)
No Display Callback: 60.0 Hz. [All Nulls Visible]
With Display Callback: 4.8 Hz. [All Nulls Visible and as little as possible attributes drawn]
With Display Callback: 4.8 Hz. [All Nulls Visible and all possible attributes drawn]
I suspect that I take the performance hit on getting stuff out of XSI...
Maybe somebody can tell me whether there are faster methods than the ones I'm using:
Get Scene Root with :
Model SceneRoot = app.GetActiveSceneRoot();
Find the nulls with:
nulls = SceneRoot.FindChildren(NULL, L"null", empty); // This is probably painful.
Get the properties of the nulls with:
CRefArray props = obj.GetProperties();
Find Visibility Property
CRef o;
if(props.Find(L"visibility", o) == CStatus::OK)
Find Parameter with
CValue val = Visibility.GetParameterValue(L"viewvis");
Find my Property
if(props.Find(L"MyProperty", o) == CStatus::OK)
Find Parameter with
CValue val1 = MyProperty.GetParameterValue(L"param1"); // This also seems less than optimal.
CValue val2 = MyProperty.GetParameterValue(L"param2");
CValue val3 = MyProperty.GetParameterValue(L"param3");
CValue val4 = MyProperty.GetParameterValue(L"param4");
CValue val5 = MyProperty.GetParameterValue(L"param5");
CValue val6 = MyProperty.GetParameterValue(L"param6");
Get null global Position with:
Kinematics Kine = obj.GetKinematics(); // This also seems a bit elaborate.
KinematicState Global = Kine.GetGlobal();
MATH::CTransformation Trans = Global.GetTransform();
double x,y,z;
Trans.GetTranslationValues(x,y,z);
Any help is welcome. Thanks.
Hans.
---------------------------------------
Hans van Veenendaal,
Sega AM plus





---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi




---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.