mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 12:43:44 -04:00
quantize hpr to eliminate small values
This commit is contained in:
parent
eaab3cbb4b
commit
45941b3fff
@ -356,27 +356,29 @@ get_r() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void DriveInterface::
|
INLINE void DriveInterface::
|
||||||
set_hpr(const LVecBase3f &hpr) {
|
set_hpr(const LVecBase3f &hpr) {
|
||||||
_hpr = hpr;
|
set_hpr(hpr[0], hpr[1], hpr[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void DriveInterface::
|
INLINE void DriveInterface::
|
||||||
set_hpr(float h, float p, float r) {
|
set_hpr(float h, float p, float r) {
|
||||||
_hpr.set(h, p, r);
|
set_h(h);
|
||||||
|
set_p(p);
|
||||||
|
set_r(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void DriveInterface::
|
INLINE void DriveInterface::
|
||||||
set_h(float h) {
|
set_h(float h) {
|
||||||
_hpr[0] = h;
|
_hpr[0] = _hpr_quantize * floor(h / _hpr_quantize + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void DriveInterface::
|
INLINE void DriveInterface::
|
||||||
set_p(float p) {
|
set_p(float p) {
|
||||||
_hpr[1] = p;
|
_hpr[1] = _hpr_quantize * floor(p / _hpr_quantize + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void DriveInterface::
|
INLINE void DriveInterface::
|
||||||
set_r(float r) {
|
set_r(float r) {
|
||||||
_hpr[2] = r;
|
_hpr[2] = _hpr_quantize * floor(r / _hpr_quantize + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "dataGraphTraverser.h"
|
#include "dataGraphTraverser.h"
|
||||||
|
|
||||||
TypeHandle DriveInterface::_type_handle;
|
TypeHandle DriveInterface::_type_handle;
|
||||||
|
const float DriveInterface::_hpr_quantize = 0.001;
|
||||||
|
|
||||||
DriveInterface::KeyHeld::
|
DriveInterface::KeyHeld::
|
||||||
KeyHeld() {
|
KeyHeld() {
|
||||||
|
@ -171,6 +171,13 @@ private:
|
|||||||
PT(EventStoreTransform) _transform;
|
PT(EventStoreTransform) _transform;
|
||||||
PT(EventStoreVec3) _velocity;
|
PT(EventStoreVec3) _velocity;
|
||||||
|
|
||||||
|
// This is the smallest meaningful value we can set on the hpr via
|
||||||
|
// the public set_hpr() interface. It's intended to filter out
|
||||||
|
// small meaningless perturbations of hpr that may get introduced
|
||||||
|
// due to numerical inaccuracy as we compute relative orientations
|
||||||
|
// in the show.
|
||||||
|
static const float _hpr_quantize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user