A workable way to copy custom parameters?

What it says on the tin: a place to discuss proposed new features.
Post Reply
matches81
Greenskin
Posts: 116
Joined: Tue Jun 12, 2007 10:28 am

A workable way to copy custom parameters?

Post by matches81 » Wed Feb 11, 2009 1:23 pm

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?
0 x

User avatar
_tommo_
Gnoll
Posts: 677
Joined: Tue Sep 19, 2006 6:09 pm
Contact:

Re: A workable way to copy custom parameters?

Post by _tommo_ » Wed Feb 11, 2009 6:08 pm

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>? :roll:
0 x
OverMindGames Blog
IndieVault.it: Il nuovo portale italiano su Game Dev & Indie Games

matches81
Greenskin
Posts: 116
Joined: Tue Jun 12, 2007 10:28 am

Re: A workable way to copy custom parameters?

Post by matches81 » Thu Feb 12, 2009 1:15 am

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.
0 x

nbeato
Gnome
Posts: 372
Joined: Thu Dec 20, 2007 1:00 am
Location: Florida
x 1
Contact:

Re: A workable way to copy custom parameters?

Post by nbeato » Thu Feb 12, 2009 5:02 pm

_tommo_ wrote:BTW, why it is a map? map<unsigned int, something_other> isn't exactly identical to vector<something_other>? :roll:
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. :roll:
0 x

User avatar
_tommo_
Gnoll
Posts: 677
Joined: Tue Sep 19, 2006 6:09 pm
Contact:

Re: A workable way to copy custom parameters?

Post by _tommo_ » Thu Feb 12, 2009 5:36 pm

Yeah should've been obvious... maybe i worked too much with C arrays :lol:
0 x
OverMindGames Blog
IndieVault.it: Il nuovo portale italiano su Game Dev & Indie Games

Post Reply