Mercurial > projects > chipmunkd
diff trunk/chipmunkd/cpBody.d @ 14:d88862c82f06
more properties
author | Extrawurst |
---|---|
date | Fri, 03 Dec 2010 23:55:20 +0100 |
parents | c03a41d47b60 |
children | df4ebc8add66 |
line wrap: on
line diff
--- a/trunk/chipmunkd/cpBody.d Fri Dec 03 21:38:01 2010 +0100 +++ b/trunk/chipmunkd/cpBody.d Fri Dec 03 23:55:20 2010 +0100 @@ -127,25 +127,48 @@ //CP_DefineBodyGetter(type, member, name) \ //CP_DefineBodySetter(type, member, name) +template CP_DefineBodyGetter(string type,string member,string name) +{ + enum CP_DefineBodyGetter = + "static "~type~" BodyGet"~name~"(const cpBody *_body){"~ + "return _body."~member~";"~ + "}"; +} + +template CP_DefineBodySetter(string type,string member,string name) +{ + enum CP_DefineBodySetter = + "static void BodySet"~name~"(cpBody *_body, const "~type~" value){"~ + "cpBodyActivate(_body);"~ + "_body."~member~" = value;"~ + "}"; +} + +template CP_DefineBodyProperty(string type,string member,string name) +{ + enum CP_DefineBodyProperty = + CP_DefineBodyGetter!(type,member,name)~CP_DefineBodySetter!(type,member,name); + +} //// Accessors for cpBody struct members -//CP_DefineBodyGetter(cpFloat, m, Mass); +mixin(CP_DefineBodyGetter!("cpFloat","m","Mass")); //void cpBodySetMass(cpBody *body, cpFloat m); // -//CP_DefineBodyGetter(cpFloat, i, Moment); +mixin(CP_DefineBodyGetter!("cpFloat","i","Moment")); //void cpBodySetMoment(cpBody *body, cpFloat i); // // -//CP_DefineBodyProperty(cpVect, p, Pos); -//CP_DefineBodyProperty(cpVect, v, Vel); -//CP_DefineBodyProperty(cpVect, f, Force); -static cpFloat cpBodyGetAngle(const cpBody *_body){return _body.a;} -static cpFloat cpBodySetAngle(cpBody *_body, const cpFloat value){cpBodyActivate(_body); return _body.a = value;} -//CP_DefineBodyProperty(cpFloat, w, AngVel); -//CP_DefineBodyProperty(cpFloat, t, Torque); -//CP_DefineBodyGetter(cpVect, rot, Rot); -//CP_DefineBodyProperty(cpFloat, v_limit, VelLimit); -//CP_DefineBodyProperty(cpFloat, w_limit, AngVelLimit); + +mixin(CP_DefineBodyProperty!("cpVect","p","Pos")); +mixin(CP_DefineBodyProperty!("cpVect","v","Vel")); +mixin(CP_DefineBodyProperty!("cpVect","f","Force")); +mixin(CP_DefineBodyProperty!("cpFloat","a","Angle")); +mixin(CP_DefineBodyProperty!("cpFloat","w","AngVel")); +mixin(CP_DefineBodyProperty!("cpFloat","t","Torque")); +mixin(CP_DefineBodyProperty!("cpVect","rot","Rot")); +mixin(CP_DefineBodyProperty!("cpFloat","v_limit","VelLimit")); +mixin(CP_DefineBodyProperty!("cpFloat","w_limit","AngVelLimit")); //// Modify the velocity of the body so that it will move to the specified absolute coordinates in the next timestep. //// Intended for objects that are moved manually with a custom velocity integration function.