I am fixing my own editor to add the feature setting an object's parent in the runtime;
but I use orxObject_SetParent to realize this feature
but it always triggered an error said:
[2011-05-05 16:39:37] <SYSTEM> (orxTree_MoveAsChild() - home/laschweinski/android/workspace/liborx_svn/code/src/utils/orxTree.c:479) Graph cycle found, invalid move.
so how to set the parent of an object in the runtime?
and what is difference between orxObject_SetParent and orxObject_SetOwner
when I use orxObject_SetOwner, there is no any error, but seems no any result I want to get.
[Edit]I have solved this....I made some mistake. but still want to know what is difference between orxObject_SetParent and orxObject_SetOwner
Comments
A parent of B parent of C parent of A => invalid
orxObject_SetOwner() isn't really of any interest for end users, it's the way some structures can assert their ownership on an object, such as a spawner on spawned objects or an object on his ChildList: ChildList actually sets both: Parent so as to get a hierarchy and Owner, so that the main objects will destroy the ones created through ChildList when he gets deleted.
So basically, you shouldn't have to use orxObject_SetOwner() unless you know what you're doing. It's mostly reserved for orx's internal needs.
when using orxObject_SetParent(A, BBB);
then I try to get A's parent by using orxObject_GetParent. its parent is not BBB (is NULL or other)
but when I add
orxObject_SetOwner(A, BBB);
its parent is BBB
but when I want to get B's child by orxObject_GetChild, there is no any A.
Now I want to get the children so as to store the child list in the config.
is this result what you design to?
if yes, I will add some more extra structure in my editor to realize the feature.
Thank you
By adding
/* Updates flags */
orxStructure_SetFlags(pstObject, orxOBJECT_KU32_FLAG_CHILD, orxOBJECT_KU32_FLAG_NONE);
it would be fine.
but do you on purpose to forget to update the flag?
Besides, I found query the child is really a low-performance operation. have to find a child in all of object. if there are lots of objects, to find only one child would be a tough task that will waste some time. is it necessary to add a childlist to the object structure?
What that flag means is that an object has been created through the config option ChildList, and only this way.
orxObject_GetChild()/_GetSibling() is linked to that ChildList option, it's not linked to the hierarchical frame parenting (orxObject_SetParent()).
I know that the names are confusing but I couldn't come with better ones.
The SetParent()/GetParent() accessors only refer to the tree hierarchy of the internally stored orxFRAMEs whereas GetChild()/GetSibling() (and, in this case, GetOwner()) refers to the ChildList feature.
GetOwner() has also other uses outside the ChildList feature.
As for performances, you're right when you say that we have to go through all the objects and that it might not be very efficient. However calling the GetChild()/GetSibling() hasn't been intended to be a frequent operation (orx uses it mainly when deleting an object so as to delete its children).
We could add two pointers to the object structure but I found the structure to be big enough (and the calls to GetChild()/GetSibling() to be rare enough) and decided to go this way.
Does it answer your questions?
but how to make child object only use parent position but do not use its scale
I try to set useParentSpace = position in config in child object, but it seems there is no result I want to get.
Regarding the UseParentSpace feature, here what's the wiki says:
It only affects objects that have an explicit ParentCamera field in their config section.
Now if you want to inherit the position and not the scale, I advise you to use a 3 nodes hierarchy instead of a 2 ones: