From 70355ffe6cf42eb0529a5e518544bedd71f4227b Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 2 Nov 2009 18:05:41 +0000 Subject: [PATCH] changed addPlane() to accept 4 parameters to directly specify a, b, c, d git-svn-id: svn://anubis/misc/OdeWorld@203 bd8a9e45-a331-0410-811e-c64571078777 --- OdeWorld.cc | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/OdeWorld.cc b/OdeWorld.cc index 4dc7a00..1b06556 100644 --- a/OdeWorld.cc +++ b/OdeWorld.cc @@ -311,19 +311,31 @@ bool OdeWorld::Object::addCapsule(refptr< std::vector > args) bool OdeWorld::Object::addPlane(refptr< std::vector > args) { - if (args->size() != 6) + float a, b, c, d; + if (args->size() == 6) + { + dMatrix3 r; + dRFromEulerAngles(r, (*args)[3], (*args)[4], (*args)[5]); + dVector3 default_plane_direction = {0, 0, 1, 0}; + dVector3 rotated_plane_direction; + dMultiply0(rotated_plane_direction, default_plane_direction, r, 1, 3, 3); + + a = rotated_plane_direction[0]; + b = rotated_plane_direction[1]; + c = rotated_plane_direction[2]; + d = m_scale * (a * (*args)[0] + b * (*args)[1] + c * (*args)[2]); + } + else if (args->size() == 4) + { + a = (*args)[0]; + b = (*args)[1]; + c = (*args)[2]; + d = (*args)[3]; + } + else + { return false; - - dMatrix3 r; - dRFromEulerAngles(r, (*args)[3], (*args)[4], (*args)[5]); - dVector3 default_plane_direction = {0, 0, 1, 0}; - dVector3 rotated_plane_direction; - dMultiply0(rotated_plane_direction, default_plane_direction, r, 1, 3, 3); - - float a = rotated_plane_direction[0]; - float b = rotated_plane_direction[1]; - float c = rotated_plane_direction[2]; - float d = m_scale * (a * (*args)[0] + b * (*args)[1] + c * (*args)[2]); + } dGeomID id = dCreatePlane(m_space, a, b, c, d); m_geoms.push_back(id);