SuperTuxKart
Loading...
Searching...
No Matches
kart_motion_state.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2008-2015 Joerg Henrichs
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty ofati
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_KART_MOTION_STATE_HPP
20#define HEADER_KART_MOTION_STATE_HPP
21
22#include <cmath>
23#include "utils/vs.hpp"
24
25#include "LinearMath/btMotionState.h"
26
33class KartMotionState : public btMotionState
34{
35private:
36 btTransform m_center_of_mass;
37
38public:
43 KartMotionState(const btTransform& start_trans = btTransform::getIdentity())
44 : m_center_of_mass(start_trans)
45
46 {
47 } // KartMotionState
48
49 // ------------------------------------------------------------------------
54 virtual void getWorldTransform(btTransform& center_of_mass) const
55 {
56 center_of_mass = m_center_of_mass;
57 } // getWorldTransform
58
59 // ------------------------------------------------------------------------
64 virtual void setWorldTransform(const btTransform &new_trans)
65 {
66 assert(!std::isnan(new_trans.getOrigin().getX()));
67 assert(!std::isnan(new_trans.getOrigin().getY()));
68 assert(!std::isnan(new_trans.getOrigin().getZ()));
69 assert(!std::isnan(new_trans.getRotation().getX()));
70 assert(!std::isnan(new_trans.getRotation().getY()));
71 assert(!std::isnan(new_trans.getRotation().getZ()));
72 assert(!std::isnan(new_trans.getRotation().getW()));
73 m_center_of_mass = new_trans;
74 } // setWorldTransform
75
76}; // KartMotionState
77
78#endif // HEADER_KART_MOTION_STATE_HPP
This is a very simple motion state implementation for bullet, which does not support any transformati...
Definition: kart_motion_state.hpp:34
KartMotionState(const btTransform &start_trans=btTransform::getIdentity())
Constructor.
Definition: kart_motion_state.hpp:43
virtual void getWorldTransform(btTransform &center_of_mass) const
Returns the current world transform.
Definition: kart_motion_state.hpp:54
virtual void setWorldTransform(const btTransform &new_trans)
Synchronizes world transform from physics to user.
Definition: kart_motion_state.hpp:64