From: Joschka B. <jbo...@un...> - 2007-06-10 09:01:13
|
Hi Hedayat, hed...@ai... wrote: > Thank you for your help. It'll really save my time. (I would probably > missed the GetWorldBoundingBox function!). :-) > A question (which will help me to understand the code better): > The original ClearPlayers functions were using GetAgentBody function > which uses FindChildSupportingClass function. It was unable to find > any Body node in the AgentAspect's children (body AgentAspect). Yes, I also noticed that. I changed the GetAgentBody method back to use the GetChildOfClass function. It should work now. > But when I modified the GetAgentBody function to use > GetChildSupportingClass (or maybe the GetChildOfClass, I don't > remember now!), it successfully returned the first Body object. (This > is the function that the GetBody function uses). Why the > FindChildSupportingClass function is unable to find an object of the > Body class while there is such an object in it's children?! Exactly this problem caused me lots of headaches yesterday, and I finally gave up to try and understand it. The Body child node is definitely there in the hierarchy, and it is easily found by GetChildOfClass, but the FindChildSupportingClass (with recursion enabled) will miss it. The FindChildSupportingClass method tries to dynamically cast the shared pointers to the nodes it finds when descending the SceneGraph, and to my understanding, a cast from a Body node to a Body node should be successful. It seems that the casted pointer will always be NULL though :-( This is not the only place where FindChildSupportingClass is used, and in other cases, it seems to work (as does ListChildrenSupportingClass which basically works the same way). Maybe it has something to do with the recursion, but from looking at the code in lib/zeitgeist/leaf.h, I couldn't find anything suggesting that. Markus, in case you read that, do you have any idea why this could happen? Cheers, Joschka |