Bullet Collision Detection & Physics Library
btQuantization.h
Go to the documentation of this file.
1#ifndef BT_GIMPACT_QUANTIZATION_H_INCLUDED
2#define BT_GIMPACT_QUANTIZATION_H_INCLUDED
3
8/*
9This source file is part of GIMPACT Library.
10
11For the latest info, see http://gimpact.sourceforge.net/
12
13Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
14email: projectileman@yahoo.com
15
16
17This software is provided 'as-is', without any express or implied warranty.
18In no event will the authors be held liable for any damages arising from the use of this software.
19Permission is granted to anyone to use this software for any purpose,
20including commercial applications, and to alter it and redistribute it freely,
21subject to the following restrictions:
22
231. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
242. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
253. This notice may not be removed or altered from any source distribution.
26*/
27
29
36{
37 //enlarge the AABB to avoid division by zero when initializing the quantization values
43 btScalar(65535.0),
44 btScalar(65535.0)) /
46}
47
49 unsigned short* out,
50 const btVector3& point,
51 const btVector3& min_bound,
52 const btVector3& max_bound,
54{
56 clampedPoint.setMax(min_bound);
57 clampedPoint.setMin(max_bound);
58
60 out[0] = (unsigned short)(v.getX() + 0.5f);
61 out[1] = (unsigned short)(v.getY() + 0.5f);
62 out[2] = (unsigned short)(v.getZ() + 0.5f);
63}
64
66 const unsigned short* vecIn,
67 const btVector3& offset,
69{
72 (btScalar)(vecIn[0]) / (bvhQuantization.getX()),
73 (btScalar)(vecIn[1]) / (bvhQuantization.getY()),
74 (btScalar)(vecIn[2]) / (bvhQuantization.getZ()));
75 vecOut += offset;
76 return vecOut;
77}
78
79#endif // BT_GIMPACT_QUANTIZATION_H_INCLUDED
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:27
void bt_calc_quantization_parameters(btVector3 &outMinBound, btVector3 &outMaxBound, btVector3 &bvhQuantization, const btVector3 &srcMinBound, const btVector3 &srcMaxBound, btScalar quantizationMargin)
void bt_quantize_clamp(unsigned short *out, const btVector3 &point, const btVector3 &min_bound, const btVector3 &max_bound, const btVector3 &bvhQuantization)
btVector3 bt_unquantize(const unsigned short *vecIn, const btVector3 &offset, const btVector3 &bvhQuantization)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
#define SIMD_FORCE_INLINE
Definition btScalar.h:98
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
const btScalar & getZ() const
Return the z value.
Definition btVector3.h:565
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition btVector3.h:640
const btScalar & getY() const
Return the y value.
Definition btVector3.h:563
const btScalar & getX() const
Return the x value.
Definition btVector3.h:561