About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
initialize struct variables to 0
Author Message
Zervox Offline
Silver Supporter

Post: #1
initialize struct variables to 0
I would like to request that these classes gets initialized to 0 on construction.
Code:
Vec2() :x(0.0f), y(0.0f) {}
Vec() :x(0.0f), y(0.0f), z(0.0f) {}
Vec4() :x(0.0f), y(0.0f), z(0.0f), w(0.0f) {}
VecD2() :x(0.0), y(0.0) {}
VecD() :x(0.0), y(0.0), z(0.0) {}
VecD4() :x(0.0), y(0.0), z(0.0), w(0.0) {}
VecI2() :x(0), y(0) {}
VecI() :x(0), y(0), z(0) {}
VecI4() :x(0), y(0), z(0), w(0) {}
Color() :r(0), g(0), b(0), a(0) {}


UID variable members should also be set to 0
Thanks. smile
(This post was last modified: 08-24-2014 12:26 AM by Zervox.)
08-24-2014 12:07 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: initialize struct variables to 0
Hi,

I understand the need, however due to performance reasons, I can't do that.
As things will run slightly slower.

However you can initialize your variables like that:
Vec x=0;
UID id=UIDZero;
Color c=TRANSPARENT;
..

alternatively you could consider doing class wrappers, something like:
class MyVec : Vec
{
MyVec() {zero();}
}
08-24-2014 04:36 AM
Find all posts by this user Quote this message in a reply
Post Reply