comparison trunk/chipmunkd/cpBody.d @ 14:d88862c82f06

more properties
author Extrawurst
date Fri, 03 Dec 2010 23:55:20 +0100
parents c03a41d47b60
children df4ebc8add66
comparison
equal deleted inserted replaced
13:c03a41d47b60 14:d88862c82f06
125 125
126 //#define CP_DefineBodyProperty(type, member, name) \ 126 //#define CP_DefineBodyProperty(type, member, name) \
127 //CP_DefineBodyGetter(type, member, name) \ 127 //CP_DefineBodyGetter(type, member, name) \
128 //CP_DefineBodySetter(type, member, name) 128 //CP_DefineBodySetter(type, member, name)
129 129
130 template CP_DefineBodyGetter(string type,string member,string name)
131 {
132 enum CP_DefineBodyGetter =
133 "static "~type~" BodyGet"~name~"(const cpBody *_body){"~
134 "return _body."~member~";"~
135 "}";
136 }
137
138 template CP_DefineBodySetter(string type,string member,string name)
139 {
140 enum CP_DefineBodySetter =
141 "static void BodySet"~name~"(cpBody *_body, const "~type~" value){"~
142 "cpBodyActivate(_body);"~
143 "_body."~member~" = value;"~
144 "}";
145 }
146
147 template CP_DefineBodyProperty(string type,string member,string name)
148 {
149 enum CP_DefineBodyProperty =
150 CP_DefineBodyGetter!(type,member,name)~CP_DefineBodySetter!(type,member,name);
151
152 }
130 153
131 //// Accessors for cpBody struct members 154 //// Accessors for cpBody struct members
132 //CP_DefineBodyGetter(cpFloat, m, Mass); 155 mixin(CP_DefineBodyGetter!("cpFloat","m","Mass"));
133 //void cpBodySetMass(cpBody *body, cpFloat m); 156 //void cpBodySetMass(cpBody *body, cpFloat m);
134 // 157 //
135 //CP_DefineBodyGetter(cpFloat, i, Moment); 158 mixin(CP_DefineBodyGetter!("cpFloat","i","Moment"));
136 //void cpBodySetMoment(cpBody *body, cpFloat i); 159 //void cpBodySetMoment(cpBody *body, cpFloat i);
137 // 160 //
138 // 161 //
139 //CP_DefineBodyProperty(cpVect, p, Pos); 162
140 //CP_DefineBodyProperty(cpVect, v, Vel); 163 mixin(CP_DefineBodyProperty!("cpVect","p","Pos"));
141 //CP_DefineBodyProperty(cpVect, f, Force); 164 mixin(CP_DefineBodyProperty!("cpVect","v","Vel"));
142 static cpFloat cpBodyGetAngle(const cpBody *_body){return _body.a;} 165 mixin(CP_DefineBodyProperty!("cpVect","f","Force"));
143 static cpFloat cpBodySetAngle(cpBody *_body, const cpFloat value){cpBodyActivate(_body); return _body.a = value;} 166 mixin(CP_DefineBodyProperty!("cpFloat","a","Angle"));
144 //CP_DefineBodyProperty(cpFloat, w, AngVel); 167 mixin(CP_DefineBodyProperty!("cpFloat","w","AngVel"));
145 //CP_DefineBodyProperty(cpFloat, t, Torque); 168 mixin(CP_DefineBodyProperty!("cpFloat","t","Torque"));
146 //CP_DefineBodyGetter(cpVect, rot, Rot); 169 mixin(CP_DefineBodyProperty!("cpVect","rot","Rot"));
147 //CP_DefineBodyProperty(cpFloat, v_limit, VelLimit); 170 mixin(CP_DefineBodyProperty!("cpFloat","v_limit","VelLimit"));
148 //CP_DefineBodyProperty(cpFloat, w_limit, AngVelLimit); 171 mixin(CP_DefineBodyProperty!("cpFloat","w_limit","AngVelLimit"));
149 172
150 //// Modify the velocity of the body so that it will move to the specified absolute coordinates in the next timestep. 173 //// Modify the velocity of the body so that it will move to the specified absolute coordinates in the next timestep.
151 //// Intended for objects that are moved manually with a custom velocity integration function. 174 //// Intended for objects that are moved manually with a custom velocity integration function.
152 //void cpBodySlew(cpBody *body, cpVect pos, cpFloat dt); 175 //void cpBodySlew(cpBody *body, cpVect pos, cpFloat dt);
153 // 176 //