Merge branch '164-crash-on-patching-and-possibly-right-after-login' into main/gingo...
[ryzomcore.git] / snowballs2 / server / position / src / physics.h
blobe857fe25fbb0683d74bc64a7e8a599ff3f48da0a
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef PHYSICS_H
18 #define PHYSICS_H
21 // Includes
24 #include <nel/misc/vector.h>
25 #include <nel/misc/time_nl.h>
28 // External classes
31 class CTrajectory
33 NLMISC::CVector _StartPosition;
34 NLMISC::CVector _EndPosition;
35 float _Speed;
36 NLMISC::TTime _StartTime;
37 NLMISC::TTime _StopTime;
38 float _Distance;
40 public:
41 void init(const NLMISC::CVector &position, const NLMISC::CVector &target, float speed, NLMISC::TTime startTime)
43 _StartPosition = position;
44 _EndPosition = target;
45 _Speed = speed;
46 _StartTime = startTime;
47 _Distance = (_EndPosition-_StartPosition).norm();
48 _StopTime = (NLMISC::TTime)(_Distance/_Speed*1000.0+_StartTime);
51 // void compute(const NLMISC::CVector &position, const NLMISC::CVector &target, float speed, NLMISC::TTime startTime);
53 NLMISC::CVector eval(NLMISC::TTime t) const;
54 NLMISC::CVector evalSpeed(NLMISC::TTime t) const;
56 NLMISC::TTime getStartTime() const { return _StartTime; }
57 NLMISC::CVector getStartPosition() const { return _StartPosition; }
58 NLMISC::TTime getStopTime() const { return _StopTime; }
61 #endif // PHYSICS_H
63 /* End of physics.h */