PDA

View Full Version : Way to query object position/rotation without triggering reevaluation?



kjl
05-29-2005, 11:15 PM
It looks like calling the param function of LWItemInfo to query an object's position sets the dirty flag for that object (i.e. it makes it evaluate again).

e.g. putting this in your Evaluate() function of an itemmotionhandler plugin:



LWDVector ParentPos;
iteminfo->param(parentID,LWIP_W_POSITION,time,ParentPos);


will cause the item defined by parentID to evaluate its position again, I think.


I have a scene with roughly 160 items controlled by itemmotionhandler plugins, each of which needs to get the world position and up/forward/right vectors from its parent.


I took my plugin and commented out the entire Evaluate() function except for a debugging fprintf to a log file, and when I loaded it in it loaded almost instantaneously and dumped ~320 debug lines in my log file.


i.e. lots of copies of this plugin loaded instantly and evaluated roughly twice per plugin instance:



XCALL_( static void )
Evaluate( MyPlug *inst, const LWItemMotionAccess *access )
{
LWDVector parentPos;
DEBUGPRINTF("EVALUATE\n"):
return;
}


Then I simply put in one param() call to get the world position of the parent and when I loaded the same scene it dumped some 80,000 lines or more of debug lines in my log file and took forever to load.


i.e. lots of copies of this plugin blew up my computer and evaluated 1000s of times per plugin instance:



XCALL_( static void )
Evaluate( MyPlug *inst, const LWItemMotionAccess *access )
{
LWDVector parentPos;
DEBUGPRINTF("EVALUATE\n"):
iteminfo->param(inst->parentid,LWIP_W_POSITION, access->time, parentPos); //just added this one line
return;
}


Is this expected behavior? It seems like the "param" function of iteminfo should not trigger reevaluation of the parent object. Am I doing something wrong, or is there another method anybody knows about to get around this? My scene is just barely usable (10 seconds or so to change frames, even if the plugin does absolutely nothing but query its parent's position once), and if I use something like FPrime that is constantly asking LW for scene information it is completely unusable (2 minutes per frame change - it takes longer to change the frame than for FPrime to render 3 passes).


I am simplifying my actual scene a little. In reality, I have hierarchies of these plugin-controlled items:
A->B->C->D->E where E is parented to D and queries D's world position, and D is parented to C and queries C's world position, etc..

Nevertheless, a single iteminfo->param call (which does NOT affect any data at all) seems like it should not cause my load and frame-change evaluation time to go up by 20 seconds from <1 second.


Thanks!