#72251 - ishraam - Fri Feb 17, 2006 5:58 am
Yo,
I'd like your opinion. And forgive me if that's somewhere stupid (it's 5.55 am I haven't had much sleep recently :p).
I was telling to myself, after reading many different threads, that working with f32 could quicly become a pain in the ass. Even writing the Vector3 class for f32 is boring (especially when it's not your first nor second nor third....time). Obviously, struggling with f32 helps a lot to get a better understanding of how things work, but once you got it...well you got it :).
When you try to keep a clean and readable code, and moreover when you want (easily) portable code , or to port some to the DS (cf. all the "doomDS", "QuakeDS",...), having to deal with "f32" and "mulf32" instead of "float" and " * " is "not friendly" (read: a little pain in the ass).
So an idea poped out of my mind : why not create a "Float" class around the f32, which redefines every operators (even the bit shifting), and has everything inlined?? Porting your C++ well written classes would then (almost) be nothing but a matter of find & replace "float" by "Float" (anyway, that's the idea behind it)
Basically:
Having everthing inlined, it should not be slower that f32, and might be worth the writing, IMHO.
I have been in DS dev only for 1 week, so I might be totally wrong.
Anyway, what's your opinion ?
I'd like your opinion. And forgive me if that's somewhere stupid (it's 5.55 am I haven't had much sleep recently :p).
I was telling to myself, after reading many different threads, that working with f32 could quicly become a pain in the ass. Even writing the Vector3 class for f32 is boring (especially when it's not your first nor second nor third....time). Obviously, struggling with f32 helps a lot to get a better understanding of how things work, but once you got it...well you got it :).
When you try to keep a clean and readable code, and moreover when you want (easily) portable code , or to port some to the DS (cf. all the "doomDS", "QuakeDS",...), having to deal with "f32" and "mulf32" instead of "float" and " * " is "not friendly" (read: a little pain in the ass).
So an idea poped out of my mind : why not create a "Float" class around the f32, which redefines every operators (even the bit shifting), and has everything inlined?? Porting your C++ well written classes would then (almost) be nothing but a matter of find & replace "float" by "Float" (anyway, that's the idea behind it)
Basically:
Code: |
struct Float { f32 val; //::::CONSTRUCTORS Float():val(inttof32(0)){} Float(float parVal):val((parVal)){} Float(f32 parVal):val(parVal){} Float(const Float & parVal):val(parVal.val){} //:::OPERATORS REDEFINED Float operator + (const Float & parF) { return Float(val+parF.val); } Float operator * (const Float & parF) { return Float(mulf32(val,parF.val)); } }; |
Having everthing inlined, it should not be slower that f32, and might be worth the writing, IMHO.
I have been in DS dev only for 1 week, so I might be totally wrong.
Anyway, what's your opinion ?