Hi there!
I'm currently trying to clone a hierarchy within a scene (i.e. clone a SceneNode with all children and attached objects) and I've encountered a problem: There's no sensible way to copy the custom parameters, because I don't have access to the CustomParameterMap each Renderable has.
The only "solution" I can come up with is to actually iterate over the size_t space and try to get the parameter, catching any exceptions... quite a lot of work when the number of actual parameters is probably significantly lower.
One idea would be to provide a copy of the CustomParameterMap accessible via a function (e.g. map<size_t, Vector4> Renderable::GetCustomParameterMap())... or, if that's impossible for some reason a function that returns a vector / list / whatever containing all used custom parameter indices.
anything wrong with that request?
A workable way to copy custom parameters?
-
- Greenskin
- Posts: 116
- Joined: Tue Jun 12, 2007 10:28 am
- _tommo_
- Gnoll
- Posts: 677
- Joined: Tue Sep 19, 2006 6:09 pm
- x 5
- Contact:
Re: A workable way to copy custom parameters?
It looks like a good request to me... anything that can be set should be "get-able".
BTW, why it is a map? map<unsigned int, something_other> isn't exactly identical to vector<something_other>?
BTW, why it is a map? map<unsigned int, something_other> isn't exactly identical to vector<something_other>?
-
- Greenskin
- Posts: 116
- Joined: Tue Jun 12, 2007 10:28 am
Re: A workable way to copy custom parameters?
AFAIK it is a map because you can address these custom parameters in your materials using the index you've assigned to them.
I haven't actually looked into using them yet, I just wanted to be as thorough as possible when cloning the hierarchy and these custom parameters seemed like something I should copy.
I haven't actually looked into using them yet, I just wanted to be as thorough as possible when cloning the hierarchy and these custom parameters seemed like something I should copy.
-
- Gnome
- Posts: 372
- Joined: Thu Dec 20, 2007 1:00 am
- Location: Florida
- x 3
- Contact:
Re: A workable way to copy custom parameters?
No it isn't identical. From a usage standpoint, the syntax is similar, that is it. My guess is that the parameters are arbitrarily assigned by the material programmer. I could make all of my parameters for a particular effect be 1000-1100 and only use 5 of the values in that range. With a vector, provided it is size 1100, traversing my 5 items will take 1100 loop iterations. With a map, it will take 5 iterations. Hence, traversing is O(max(params)) vs. O(count(params)). Space-wise, the vector require O(max(params)) storage while the map is O(count(param)) storage, so the footprint makes a difference. The vector slightly wins in random access time. A vector is O(1) while a map is O(log count(params)), which for 5 params is 3 iterations. The vector wins if your profiler tells you that random access is killing your program. Otherwise, the map makes much sense._tommo_ wrote:BTW, why it is a map? map<unsigned int, something_other> isn't exactly identical to vector<something_other>?
- _tommo_
- Gnoll
- Posts: 677
- Joined: Tue Sep 19, 2006 6:09 pm
- x 5
- Contact:
Re: A workable way to copy custom parameters?
Yeah should've been obvious... maybe i worked too much with C arrays