Fix float precision issues in bulletHeightfieldShape

Closes: #152
This commit is contained in:
The Cheaterman 2015-08-13 02:30:31 +02:00 committed by rdb
parent 2b537d2263
commit 86cbdddd76
3 changed files with 10 additions and 10 deletions

View File

@ -30,8 +30,8 @@ BulletHeightfieldShape(const BulletHeightfieldShape &copy) :
_num_rows(copy._num_rows),
_num_cols(copy._num_cols) {
_data = new float[_num_rows * _num_cols];
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float));
_data = new btScalar[_num_rows * _num_cols];
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(btScalar));
}
/**
@ -44,6 +44,6 @@ operator = (const BulletHeightfieldShape &copy) {
_num_rows = copy._num_rows;
_num_cols = copy._num_cols;
_data = new float[_num_rows * _num_cols];
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float));
_data = new btScalar[_num_rows * _num_cols];
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(btScalar));
}

View File

@ -26,7 +26,7 @@ BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAx
_num_rows = image.get_x_size();
_num_cols = image.get_y_size();
_data = new float[_num_rows * _num_cols];
_data = new btScalar[_num_rows * _num_cols];
for (int row=0; row < _num_rows; row++) {
for (int column=0; column < _num_cols; column++) {
@ -75,10 +75,10 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) {
_num_rows = tex->get_x_size() + 1;
_num_cols = tex->get_y_size() + 1;
_data = new float[_num_rows * _num_cols];
_data = new btScalar[_num_rows * _num_cols];
PN_stdfloat step_x = 1.0 / (PN_stdfloat)tex->get_x_size();
PN_stdfloat step_y = 1.0 / (PN_stdfloat)tex->get_y_size();
btScalar step_x = 1.0 / (btScalar)tex->get_x_size();
btScalar step_y = 1.0 / (btScalar)tex->get_y_size();
PT(TexturePeeker) peeker = tex->peek();
LColor sample;
@ -100,4 +100,4 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) {
up,
true, false);
_shape->setUserPointer(this);
}
}

View File

@ -44,7 +44,7 @@ public:
private:
int _num_rows;
int _num_cols;
float *_data;
btScalar *_data;
btHeightfieldTerrainShape *_shape;
public: