1 | // Copyright (C) 2016 ChaosForge Ltd
|
---|
2 | // http://chaosforge.org/
|
---|
3 | //
|
---|
4 | // This file is part of Nova libraries.
|
---|
5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * @file bullet_helper.hh
|
---|
9 | * @author Kornel Kisielewicz
|
---|
10 | * @brief bullet helper functions
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef NV_BULLET_HELPER_HH
|
---|
14 | #define NV_BULLET_HELPER_HH
|
---|
15 |
|
---|
16 | #include <nv/common.hh>
|
---|
17 | #include <nv/stl/math.hh>
|
---|
18 | #include <nv/core/transform.hh>
|
---|
19 | #include <LinearMath/btVector3.h>
|
---|
20 | #include <LinearMath/btQuaternion.h>
|
---|
21 | #include <LinearMath/btTransform.h>
|
---|
22 |
|
---|
23 | namespace nv
|
---|
24 | {
|
---|
25 | btVector3 n2b( vec3 v )
|
---|
26 | {
|
---|
27 | return btVector3( v.x, v.y, v.z );
|
---|
28 | }
|
---|
29 |
|
---|
30 | vec3 b2n( const btVector3& v )
|
---|
31 | {
|
---|
32 | return vec3( v.getX(), v.getY(), v.getZ() );
|
---|
33 | }
|
---|
34 |
|
---|
35 | btQuaternion n2b( quat v )
|
---|
36 | {
|
---|
37 | return btQuaternion( v.x, v.y, v.z, v.w );
|
---|
38 | }
|
---|
39 |
|
---|
40 | quat b2n( const btQuaternion& v )
|
---|
41 | {
|
---|
42 | return quat( v.getW(), v.getX(), v.getY(), v.getZ() );
|
---|
43 | }
|
---|
44 |
|
---|
45 | btTransform n2b( transform tr )
|
---|
46 | {
|
---|
47 | return btTransform( n2b( tr.get_orientation() ), n2b( tr.get_position() ) );
|
---|
48 | }
|
---|
49 |
|
---|
50 | transform b2n( const btTransform& v )
|
---|
51 | {
|
---|
52 | return transform( b2n( v.getOrigin() ), b2n( v.getRotation() ) );
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|
56 | #endif // NV_BULLET_HELPER_HH
|
---|