1 /*************************************************************************
3 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of EITHER: *
8 * (1) The GNU Lesser General Public License as published by the Free *
9 * Software Foundation; either version 2.1 of the License, or (at *
10 * your option) any later version. The text of the GNU Lesser *
11 * General Public License is included with this library in the *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
16 * This library is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
21 *************************************************************************/
24 #ifndef _ODE_GIMPACT_GIM_CONTACT_ACCESSOR_H_
25 #define _ODE_GIMPACT_GIM_CONTACT_ACCESSOR_H_
28 struct dxGIMCContactAccessor
30 dxGIMCContactAccessor(GIM_CONTACT
*ptrimeshcontacts
, dGeomID g1
, dGeomID g2
) : m_ptrimeshcontacts(ptrimeshcontacts
), m_g1(g1
), m_g2(g2
), m_gotside2ovr(false), m_side2ovr() {}
31 dxGIMCContactAccessor(GIM_CONTACT
*ptrimeshcontacts
, dGeomID g1
, dGeomID g2
, int side2ovr
) : m_ptrimeshcontacts(ptrimeshcontacts
), m_g1(g1
), m_g2(g2
), m_gotside2ovr(true), m_side2ovr(side2ovr
) {}
33 dReal
RetrieveDepthByIndex(unsigned index
) const { return m_ptrimeshcontacts
[index
].m_depth
; }
35 void ExportContactGeomByIndex(dContactGeom
*pcontact
, unsigned index
) const
37 const GIM_CONTACT
*ptrimeshcontact
= m_ptrimeshcontacts
+ index
;
38 pcontact
->pos
[0] = ptrimeshcontact
->m_point
[0];
39 pcontact
->pos
[1] = ptrimeshcontact
->m_point
[1];
40 pcontact
->pos
[2] = ptrimeshcontact
->m_point
[2];
41 pcontact
->pos
[3] = REAL(1.0);
43 pcontact
->normal
[0] = ptrimeshcontact
->m_normal
[0];
44 pcontact
->normal
[1] = ptrimeshcontact
->m_normal
[1];
45 pcontact
->normal
[2] = ptrimeshcontact
->m_normal
[2];
46 pcontact
->normal
[3] = 0;
48 pcontact
->depth
= ptrimeshcontact
->m_depth
;
51 pcontact
->side1
= ptrimeshcontact
->m_feature1
;
52 pcontact
->side2
= !m_gotside2ovr
? ptrimeshcontact
->m_feature2
: m_side2ovr
;
55 const GIM_CONTACT
*m_ptrimeshcontacts
;
62 #endif //_ODE_GIMPACT_GIM_CONTACT_ACCESSOR_H_