1 //metadoc ODEPlane copyrigth Jonathan Wright, 2006
2 //metadoc ODEPlane license BSD revised
3 /*metadoc ODEPlane description
7 #include "IoODEPlane.h"
10 #include "IoVector_ode.h"
14 #define DATA(self) ((IoODEPlaneData *)IoObject_dataPointer(self))
15 #define GEOMID (DATA(self)->geomId)
17 IoTag
*IoODEPlane_newTag(void *state
)
19 IoTag
*tag
= IoTag_newWithName_("ODEPlane");
20 IoTag_state_(tag
, state
);
21 IoTag_freeFunc_(tag
, (IoTagFreeFunc
*)IoODEPlane_free
);
22 IoTag_cloneFunc_(tag
, (IoTagCloneFunc
*)IoODEPlane_rawClone
);
26 IoODEPlane
*IoODEPlane_proto(void *state
)
28 IoObject
*self
= IoObject_new(state
);
29 IoObject_tag_(self
, IoODEPlane_newTag(state
));
31 IoObject_setDataPointer_(self
, calloc(1, sizeof(IoODEPlaneData
)));
35 IoState_registerProtoWithFunc_(state
, self
, IoODEPlane_proto
);
38 IoMethodTable methodTable
[] = {
39 {"geomId", IoODEPlane_geomId
},
40 {"params", IoODEPlane_params
},
41 {"setParams", IoODEPlane_setParams
},
42 {"collide", IoODEGeom_collide
},
46 IoObject_addMethodTable_(self
, methodTable
);
51 IoODEPlane
*IoODEPlane_rawClone(IoODEPlane
*proto
)
53 IoObject
*self
= IoObject_rawClonePrimitive(proto
);
54 IoObject_setDataPointer_(self
, calloc(1, sizeof(IoODEPlaneData
)));
58 IoODEPlane
*IoODEPlane_new(void *state
, dGeomID geomId
)
60 IoODEPlane
*proto
= IoState_protoWithInitFunction_(state
, IoODEPlane_proto
);
61 IoODEPlane
*self
= IOCLONE(proto
);
63 dGeomSetData(GEOMID
, self
);
67 void IoODEPlane_free(IoODEPlane
*self
)
75 free(IoObject_dataPointer(self
));
78 void IoODEPlane_mark(IoODEPlane
*self
)
82 /* ----------------------------------------------------------- */
84 dGeomID
IoODEPlane_rawGeomId(IoODEPlane
*self
)
89 /* ----------------------------------------------------------- */
91 void IoODEPlane_assertHasPlaneId(IoODEPlane
*self
, IoObject
*locals
, IoMessage
*m
)
93 IOASSERT(GEOMID
, "ODE Plane cannot be used directly. Clone the space and use the clone.");
97 IoObject
*IoODEPlane_geomId(IoODEPlane
*self
, IoObject
*locals
, IoMessage
*m
)
99 return IONUMBER((long)GEOMID
);
102 IoObject
*IoODEPlane_params(IoODEPlane
*self
, IoObject
*locals
, IoMessage
*m
)
105 IoODEPlane_assertHasPlaneId(self
, locals
, m
);
106 dGeomPlaneGetParams(GEOMID
, params
);
107 return IoVector_newWithODEVector4(IOSTATE
, params
);
110 IoObject
*IoODEPlane_setParams(IoODEPlane
*self
, IoObject
*locals
, IoMessage
*m
)
112 dReal a
= IoMessage_locals_doubleArgAt_(m
, locals
, 0);
113 dReal b
= IoMessage_locals_doubleArgAt_(m
, locals
, 1);
114 dReal c
= IoMessage_locals_doubleArgAt_(m
, locals
, 2);
115 dReal d
= IoMessage_locals_doubleArgAt_(m
, locals
, 3);
117 IoODEPlane_assertHasPlaneId(self
, locals
, m
);
118 dGeomPlaneSetParams(GEOMID
, a
, b
, c
, d
);